- 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 the $y$-intercept and the slope of the straight line$$ f(x) = a + b(x - \alpha). $$- Parameters:
-
- xarray_like
The $x$ data.
- yarray_like
The $y$ data.
- sigma_xarray_like | None
The standard deviation $\sigma_x$ of the
xdata.- sigma_yarray_like | None
The standard deviation $\sigma_y$ of the
ydata.- corrarray_like | None
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.
- kwargs
Additional keyword arguments are passed to the fitting routine.
- Returns:
- Raises:
-
- ValueError
If
funcis not supported.