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.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_fit and linear_monte_carlo that 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 x data.

sigma_yarray_like

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

corrndarray | Iterable

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

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 given alpha as a starting point. May not give the desired result if alpha was 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.

API navigation