- qspec.analyze. King.fit ( a , a_ref , x = None , y = None , xy = None , func = 'york_fit' , alpha = 0 , find_alpha = False , show = True , ** kwargs )[source]
Perform $2$-dimensional linear regression to create a King plot. Choose between
{'york_fit' (default), 'linear_fit', 'linear_monte_carlo'}for the fit routine. Use a parameteralphato optimize the correlation coefficient between the $y$-intercept and the slope.- Parameters:
-
- andarray | Iterable
An Iterable of the mass numbers $A$ of the used isotopes.
- a_refndarray | Iterable
An Iterable of the mass numbers $A_\mathrm{ref}$ of the used reference isotopes.
- xndarray | Iterable
The $x$ data and their standard deviations as shape
(len(a), 2)arrays. If plotted withmode == 'radii', the differences of mean-square nuclear charge radii $\delta\langle r^2\rangle^{A,A_\mathrm{ref}}$ or $\Lambda^{A,A_\mathrm{ref}}$ are expected, else isotope shifts $\delta\nu_x^{A,A_\mathrm{ref}}$ are expected. Expected units: (fm$^2$) or (MHz). IfxisNone,yis tried to be inherited fromKing.x_abs.- yndarray | Iterable
The isotope shifts $\delta\nu_y^{A,A_\mathrm{ref}}$ and their standard deviations as shape
(len(a), 2)arrays. Expected units: (MHz). IfNone,yis tried to be inherited fromKing.x_abs.- xyIterable[int]
A 2-tuple of indices
(ix, iy), used to select the two plot axes fromKing.x_abs. Only used ifxoryis not specified. The default value is(0, 1), fitting the second against the first axis.- funcstr | Callable
The fitting routine. Must be one of
{'york_fit' (default), 'linear_fit', 'linear_monte_carlo'}.- alphascalar
An $x$-axis offset $\alpha$ to reduce the correlation coefficient between the $y$-intercept and the slope. Expected unit: (u fm$^2$) or (u MHz).
- 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.- showbool
Whether to plot the fit result.
- kwargsNone
Additional keyword arguments are passed to
King.plot.
- Returns:
-
- (popt, pcov)(ndarray, ndarray)
The best y-intercept and slope and their covariance matrix. The final
alphacan be accessed throughKing.alpha.