solarwindpy.fitfunctions.gaussians.GaussianLnο
- class GaussianLn(xobs, yobs, **kwargs)[source]ο
Bases:
FitFunctionLog-normal distribution for skewed data fitting.
Fits a Gaussian in logarithmic space where \(\ln(x)\) follows a normal distribution.
References
- __init__(xobs, yobs, **kwargs)[source]ο
Initialize log-normal Gaussian fit.
- Parameters:
xobs (array-like) β Observed x values (independent variable). Shape must match yobs.
yobs (array-like) β Observed y values (dependent variable). Shape must match xobs.
**kwargs β The description is missing.
Notes
xobs must be positive for log transformation. This distribution is commonly used for particle size distributions and velocity distributions in solar wind where values are positively skewed.
Examples
>>> import numpy as np >>> from solarwindpy.fitfunctions import Gaussian >>> x = np.linspace(-5, 5, 100) >>> y = 3 * np.exp(-0.5 * x**2) + np.random.normal(0, 0.1, 100) >>> fit = Gaussian(x, y, xmin=-3, xmax=3) >>> fit.make_fit() >>> print(f"Fitted mu: {fit.popt['mu']:.3f}")
- property functionο
Get the function that`curve_fit` fits.
The function is set at instantiation. It doesnβt make sense to change it unless you redefine the entire FitFunction, so there is no new kwarg.
- property p0ο
Return initial guesses
[ln(mu), ln(sigma), ln(A)].
- property TeX_functionο
Function written in LaTeX.
- property normal_parametersο
Calculate the normal parameters from log-normal parameters.
\[\mu = \exp[m + (s^2)/2] \sigma = \sqrt{\exp[s^2 + 2m] (\exp[s^2] - 1)}\]
- property TeX_report_normal_parametersο
Report normal parameters, not log-normal parameters in the TeX info.
- property TeX_poptο
Create a dictionary with
(k, v)pairs corresponding to parameter values.(self.argnames, :math:`p_{\mathrm{opt}} \pm \sigma_p`)with the appropriate uncertainty.See
set_TeX_trans_argnamesto translate the argnames for TeX.
- property TeX_infoο
- property argnamesο
The names of the actual function arguments pulled by getfullargspec.
- build_TeX_info()ο
- build_plotter()ο
- property chisq_dofο
Chisq per degree of freedom \(\chi^2_\nu\).
If None, not calculated by make_fit_old. If np.nan, fit failed.
- property combined_popt_psigmaο
Convenience to extract all versions of the optimized parameters.
- property dofο
Degrees of freedom in the fit.
- property fit_boundsο
Bounds used when running the fit.
- property fit_resultο
- property initial_guess_infoο
- property loggerο
- make_fit(return_exception=False, **kwargs)ο
Fit the function with the independent xobs and dependent yobs.
Uses least_squares and returns the OptimizeResult object, but treats weights as in curve_fit.
- Parameters:
return_exception (bool) β If True, return exceptions from fitting routine, instead of raising. This is useful when looping through many fits and wanting to identify failed fits after the fact.
**kwargs β The description is missing.
- property nobsο
The total number of observations used in the fit.
- property observationsο
- property pcovο
Returns a copy so that the matrix isnβt accidentally edited.
- property plotterο
- property poptο
Optimized fit parameters.
- property psigmaο
- property psigma_relativeο
- residuals(pct=False)ο
Calculate the fit residuals.
If pct, normalize by fit yvalues.
- Parameters:
pct β The description is missing.
- property rsqο
Coefficient of determination.
Source: <en.wikipedia.org/wiki/Coefficient_of_determination#Definitions>
- set_fit_obs(xobs_raw, yobs_raw, weights_raw, xmin=None, xmax=None, xoutside=None, ymin=None, ymax=None, youtside=None, wmin=None, wmax=None, logx=False, logy=False)ο
Set the observed values weβll actually use in the fit.
By applying limits to xobs_raw and yobs_raw and checking for finite values.
All boundaries are inclusive <= or >=.
If logy, then make selection of wmin and wmax based on \(w/(y \ln(10))\).
- Parameters:
xobs_raw β The description is missing.
yobs_raw β The description is missing.
weights_raw β The description is missing.
xmin β The description is missing.
xmax β The description is missing.
xoutside β The description is missing.
ymin β The description is missing.
ymax β The description is missing.
youtside β The description is missing.
wmin β The description is missing.
wmax β The description is missing.
logx β The description is missing.
logy β The description is missing.
- property sufficient_dataο
Ensure that we can fit the data before doing any computations.