- 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:
-
- xarray_like
The $x$ data.
- yarray_like
The $y$ data.
- sigma_xarray_like | None
The standard deviation $\sigma_x$ of the
xdata. IfNone, it is 1.- sigma_yarray_like | None
The standard deviation $\sigma_y$ of the
ydata. IfNone, it is 1.- corrarray_like | None
The correlation coefficients $\rho_{xy}$ between the
xandydata. IfNone, it is 0.- 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.
- kwargs
Additional keyword arguments are accepted for compatibility with the other linear regression algorithms and ignored.
- Returns:
- Raises:
-
- ValueError
If the optimization fails.