- qspec.analyze.linear_alpha_fit ( x , y , sigma_x = None , sigma_y = None , corr = None , func = 'york_fit' , alpha = 0 , find_alpha = True , report = False , show = False , ** kwargs )[source]
Wrapper for the $2$-dimensional linear regression algorithms
york_fit,linear_fitandlinear_monte_carlothat optimizes an additional $x$-axis shift $\alpha$ for the minimum correlation coefficient between $y$-intercept and slope.- Parameters:
-
- xndarray | Iterable
The $x$ data.
- yndarray | Iterable
The $y$ data.
- sigma_xarray_like
The standard deviation $\sigma_x$ of the
xdata.- sigma_yarray_like
The standard deviation $\sigma_y$ of the
ydata.- corrndarray | Iterable
The correlation coefficients $\rho_{xy}$ between the
xandydata.- funcCallable | str
The fitting routine. Supports any of
{'york_fit', 'linear_fit', 'linear_monte_carlo'}.- alphascalar
An $x$-axis offset $\alpha$ to reduce the correlation coefficient between the $y$-intercept and the slope.
- find_alphabool
Whether to search for the best
alpha. Uses the givenalphaas a starting point. May not give the desired result ifalphawas initialized too far from its optimal value.- reportbool
Whether to print the result of the fit.
- showbool
Whether to plot the fit result.
- kwargsNone
Additional keyword arguments are passed to the fitting routine.
- Returns:
-
- (popt, pcov, alpha)(ndarray, ndarray, float)
. The best y-intercept and slope, their covariance matrix and the final
alpha.