erlab.analysis.fit.minuit¶
Classes
|
|
|
A thin wrapper around |
|
|
|
All the operations on a read-only sequence. |
- class erlab.analysis.fit.minuit.LeastSq(x, y, yerror, model, *, loss='linear', verbose=0, grad=None, name=None)[source]¶
Bases:
LeastSquaresA thin wrapper around
iminuit.cost.LeastSquaresthat produces better plots.- visualize(args, model_points=0)[source]¶
Visualize data and model agreement (requires matplotlib).
The visualization is drawn with matplotlib.pyplot into the current axes.
- Parameters:
args (
array-like) – Parameter values.model_points (
intorarray-like, optional) – How many points to use to draw the model. Default is 0, in this case an smart sampling algorithm selects the number of points. If array-like, it is interpreted as the point locations.
- class erlab.analysis.fit.minuit.Minuit(fcn, *args, grad=None, g2=None, hessian=None, name=None, **kwds)[source]¶
Bases:
Minuitiminuit.Minuitwith additional functionality.This class extends the functionality of the
iminuit.Minuitclass by providing a convenient methodfrom_lmfitto initialize theMinuitobject from anlmfit.Modelobject.For more information on the
iminuitlibrary, see its documentation.Examples
>>> import lmfit.models >>> import numpy as np >>> from erlab.analysis.fit.minuit import Minuit
>>> # Create an lmfit.Model object >>> model = lmfit.models.LinearModel()
>>> # Generate some data >>> x = np.linspace(0, 10, 100) >>> y = model.eval(x=x, a=2, b=1) >>> rng = np.random.default_rng(1) >>> y = rng.normal(y, 0.5)
>>> # Initialize a Minuit object from the lmfit.Model object >>> m = Minuit.from_lmfit(model, y, x)
>>> # Perform the fit >>> m.migrad()