Logo

A physics toolbox for laser spectroscopy.

Static Badge Static Badge Static Badge

Static Badge Static Badge

© 2025 Patrick Müller. All rights reserved.

qspec.analyze.york_fit  (  x y sigma_x = None sigma_y = None corr = None iter_max = 200 report = False show = False ** kwargs  )[source]

A linear regression algorithm to find the best straight line through points $\vec{\mu}_i\in\mathbb{R}^2$ with covariances $\mathbf{\Sigma}_i\in\mathbb{R}^{2\times 2}$, assuming $2$-dimensional multivariate normal distributions $\mathcal{N}(\vec{\mu}_i, \mathbf{\Sigma}_i)$. The data points and covariances are given by $$\vec{\mu} = \begin{pmatrix}x\\y\end{pmatrix},\quad \mathbf{\Sigma} = \begin{pmatrix} \sigma_x^2 & \rho_{xy}\sigma_x\sigma_y \\ \rho_{xy}\sigma_x\sigma_y & \sigma_y^2 \end{pmatrix}.$$ The algorithm is described in [York et al., Am. J. Phys. 72, 367 (2004)].

Parameters:
xndarray | Iterable

The $x$ data.

yndarray | Iterable

The $y$ data.

sigma_xndarray | Iterable

The standard deviation $\sigma_x$ of the x data.

sigma_yndarray | Iterable

The standard deviation $\sigma_y$ of the y data.

corrndarray | Iterable

The correlation coefficients $\rho_{xy}$ between the x and y data.

iter_maxint

The maximum number of iterations to find the best slope.

reportbool

Whether to print the result of the fit.

showbool

Whether to plot the fit result.

kwargsNone

Additional keyword arguments.

Returns:
(popt, pcov)(ndarray, ndarray)

The best y-intercept and slope and their covariance matrix.

API navigation