Computation times¶
│ │ │ -00:45.345 total execution time for examples files:
│ │ │ +03:30.400 total execution time for examples files:
│ │ │Global minimization using the brute method (a.k.a. grid search) ( |
│ │ │ -00:23.896 |
│ │ │ +02:16.137 |
│ │ │ 0.0 MB |
│ │ │
Calculate Confidence Intervals ( |
│ │ │ -00:18.734 |
│ │ │ +01:05.346 |
│ │ │ 0.0 MB |
│ │ │
Outlier detection via leave-one-out ( |
│ │ │ -00:00.772 |
│ │ │ +00:03.183 |
│ │ │ 0.0 MB |
│ │ │
Fit Using differential_evolution Algorithm ( |
│ │ │ -00:00.414 |
│ │ │ +00:01.090 |
│ │ │ 0.0 MB |
│ │ │
Fit with Data in a pandas DataFrame ( |
│ │ │ -00:00.235 |
│ │ │ +||
Fit using the Model interface ( |
│ │ │ +00:00.769 |
│ │ │ 0.0 MB |
│ │ │ |
Complex Resonator Model ( |
│ │ │ -00:00.223 |
│ │ │ +00:00.682 |
│ │ │ 0.0 MB |
│ │ │
Fit using the Model interface ( |
│ │ │ -00:00.192 |
│ │ │ +||
Fit Multiple Data Sets ( |
│ │ │ +00:00.547 |
│ │ │ 0.0 MB |
│ │ │ |
Fit Using Inequality Constraint ( |
│ │ │ -00:00.175 |
│ │ │ +||
Fit with Data in a pandas DataFrame ( |
│ │ │ +00:00.481 |
│ │ │ 0.0 MB |
│ │ │ |
Using an ExpressionModel ( |
│ │ │ -00:00.166 |
│ │ │ +||
Fit Specifying Different Reduce Function ( |
│ │ │ +00:00.464 |
│ │ │ 0.0 MB |
│ │ │ |
Fit Specifying Different Reduce Function ( |
│ │ │ -00:00.130 |
│ │ │ +||
Using an ExpressionModel ( |
│ │ │ +00:00.452 |
│ │ │ 0.0 MB |
│ │ │ |
Fit Multiple Data Sets ( |
│ │ │ -00:00.124 |
│ │ │ +||
Fit with Algebraic Constraint ( |
│ │ │ +00:00.349 |
│ │ │ 0.0 MB |
│ │ │ |
Fit Using Bounds ( |
│ │ │ -00:00.107 |
│ │ │ +||
Fit Using Inequality Constraint ( |
│ │ │ +00:00.319 |
│ │ │ 0.0 MB |
│ │ │ |
Fit with Algebraic Constraint ( |
│ │ │ -00:00.101 |
│ │ │ +||
Fit Using Bounds ( |
│ │ │ +00:00.299 |
│ │ │ 0.0 MB |
│ │ │ |
Fit Specifying a Function to Compute the Jacobian ( |
│ │ │ -00:00.077 |
│ │ │ +00:00.280 |
│ │ │ 0.0 MB |
│ │ │
Model Selection using lmfit and emcee ( |
│ │ │ 00:00.000 |
│ │ │ 0.0 MB |
│ │ │
-
│ │ │
- Parameters │ │ │
-
│ │ │
params (
Parameters
, optional) – Parameters to use as starting point.
│ │ │ -max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 2000*(nvars+1), │ │ │ +
max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 2000*(nvars+1), │ │ │ where nvars is the number of variable parameters.
│ │ │ -**kws (dict, optional) – Minimizer options to pass to scipy.optimize.leastsq.
│ │ │ +**kws (dict, optional) – Minimizer options to pass to scipy.optimize.leastsq.
│ │ │
│ │ │ - Returns │ │ │
Object containing the optimized parameter │ │ │ and several goodness-of-fit statistics.
│ │ │
│ │ │ - Return type │ │ │ @@ -1215,17 +1215,17 @@ │ │ │ support for bounds and robust loss functions. By default it uses the │ │ │ Trust Region Reflective algorithm with a linear loss function (i.e., │ │ │ the standard least-squares problem). │ │ │
- Parameters │ │ │
-
│ │ │
params (
Parameters
, optional) – Parameters to use as starting point.
│ │ │ -max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 1000*(nvars+1), │ │ │ +
max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 1000*(nvars+1), │ │ │ where nvars is the number of variable parameters.
│ │ │ -**kws (dict, optional) – Minimizer options to pass to scipy.optimize.least_squares.
│ │ │ +**kws (dict, optional) – Minimizer options to pass to scipy.optimize.least_squares.
│ │ │
│ │ │ - Returns │ │ │
Object containing the optimized parameter and several │ │ │ goodness-of-fit statistics.
│ │ │
│ │ │ - Return type │ │ │ @@ -1270,15 +1270,15 @@ │ │ │
- Parameters │ │ │
-
│ │ │ -
method (str, optional) –
Name of the fitting method to use. One of:
│ │ │ +method (str, optional) –
Name of the fitting method to use. One of:
│ │ │-
│ │ │
’Nelder-Mead’ (default)
│ │ │ ’L-BFGS-B’
│ │ │ ’Powell’
│ │ │ ’CG’
│ │ │ ’Newton-CG’
│ │ │ ’COBYLA’
│ │ │ @@ -1290,17 +1290,17 @@
│ │ │ ’trust-constr’
│ │ │ ’dogleg’
│ │ │ ’SLSQP’
│ │ │ ’differential_evolution’
│ │ │
│ │ │ params (
Parameters
, optional) – Parameters to use as starting point.
│ │ │ -max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 1000*(nvars+1), │ │ │ +
max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 1000*(nvars+1), │ │ │ where nvars is the number of variable parameters.
│ │ │ -**kws (dict, optional) – Minimizer options pass to scipy.optimize.minimize.
│ │ │ +**kws (dict, optional) – Minimizer options pass to scipy.optimize.minimize.
│ │ │
│ │ │ - Returns │ │ │
Object containing the optimized parameter and several │ │ │ goodness-of-fit statistics.
│ │ │
│ │ │ - Return type │ │ │ @@ -1390,20 +1390,20 @@ │ │ │
- Parameters │ │ │
-
│ │ │
params (
Parameters
, optional) – Contains the Parameters for the model. If None, then the │ │ │ Parameters used to initialize the Minimizer object are used.
│ │ │ -Ns (int, optional) – Number of grid points along the axes, if not otherwise specified │ │ │ +
Ns (int, optional) – Number of grid points along the axes, if not otherwise specified │ │ │ (see Notes).
│ │ │ -keep (int, optional) – Number of best candidates from the brute force method that are │ │ │ +
keep (int, optional) – Number of best candidates from the brute force method that are │ │ │ stored in the
candidates
attribute. If ‘all’, then all grid │ │ │ points from scipy.optimize.brute are stored as candidates.
│ │ │ -workers (int or map-like callable, optional) – For parallel evaluation of the grid, added in SciPy v1.3 (see │ │ │ +
workers (int or map-like callable, optional) – For parallel evaluation of the grid, added in SciPy v1.3 (see │ │ │ scipy.optimize.brute for more details).
│ │ │
│ │ │ - Returns │ │ │
Object containing the parameters from the brute force method. │ │ │ The return values (x0, fval, grid, Jout) from │ │ │ scipy.optimize.brute are stored as brute_<parname> attributes. │ │ │ @@ -1491,15 +1491,15 @@ │ │ │
AMPGO stands for ‘Adaptive Memory Programming for Global Optimization’ │ │ │ and is an efficient algorithm to find the global minimum.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
params (
Parameters
, optional) – Contains the Parameters for the model. If None, then the │ │ │ Parameters used to initialize the Minimizer object are used.
│ │ │ -**kws (dict, optional) –
Minimizer options to pass to the ampgo algorithm, the options are │ │ │ +
**kws (dict, optional) –
Minimizer options to pass to the ampgo algorithm, the options are │ │ │ listed below:
│ │ ││ │ │ -│ │ │local: str (default is 'L-BFGS-B') │ │ │ Name of the local minimization method. Valid options are: │ │ │ - 'L-BFGS-B' │ │ │ - 'Nelder-Mead' │ │ │ - 'Powell' │ │ │ - 'TNC' │ │ │ @@ -1565,18 +1565,18 @@ │ │ │
SHGO stands for “simplicial homology global optimization” and calls │ │ │ scipy.optimize.shgo using its default arguments.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
params (
Parameters
, optional) – Contains the Parameters for the model. If None, then the │ │ │ Parameters used to initialize the Minimizer object are used.
│ │ │ -max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to │ │ │ +
max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to │ │ │ 1e6*(result.nvarys+1), where nvars is the number of variable │ │ │ parameters.
│ │ │ -**kws (dict, optional) – Minimizer options to pass to the SHGO algorithm.
│ │ │ +**kws (dict, optional) – Minimizer options to pass to the SHGO algorithm.
│ │ │
│ │ │ - Returns │ │ │
Object containing the parameters from the SHGO method. │ │ │ The return values specific to scipy.optimize.shgo (x, │ │ │ xl, fun, funl, nfev, nit, nlfev, nlhev, and │ │ │ nljev) are stored as shgo_<parname> attributes.
│ │ │ @@ -1597,16 +1597,16 @@ │ │ │This method calls scipy.optimize.dual_annealing using its │ │ │ default arguments.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
params (
Parameters
, optional) – Contains the Parameters for the model. If None, then the │ │ │ Parameters used to initialize the Minimizer object are used.
│ │ │ -max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 1e7.
│ │ │ -**kws (dict, optional) – Minimizer options to pass to the dual_annealing algorithm.
│ │ │ +max_nfev (int or None, optional) – Maximum number of function evaluations. Defaults to 1e7.
│ │ │ +**kws (dict, optional) – Minimizer options to pass to the dual_annealing algorithm.
│ │ │
│ │ │ - Returns │ │ │
Object containing the parameters from the dual_annealing method. │ │ │ The return values specific to scipy.optimize.dual_annealing │ │ │ (x, fun, nfev, nhev, njev, and nit) are stored as │ │ │ da_<parname> attributes.
│ │ │ @@ -1628,55 +1628,55 @@ │ │ │The method assumes that the prior is Uniform. You need to have emcee │ │ │ version 3 installed to use this method.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
params (
Parameters
, optional) – Parameters to use as starting point. If this is not specified then │ │ │ the Parameters used to initialize the Minimizer object are used.
│ │ │ -steps (int, optional) – How many samples you would like to draw from the posterior │ │ │ +
steps (int, optional) – How many samples you would like to draw from the posterior │ │ │ distribution for each of the walkers?
│ │ │ -nwalkers (int, optional) – Should be set so \(nwalkers >> nvarys\), where nvarys are │ │ │ +
nwalkers (int, optional) – Should be set so \(nwalkers >> nvarys\), where nvarys are │ │ │ the number of parameters being varied during the fit. │ │ │ ‘Walkers are the members of the ensemble. They are almost like │ │ │ separate Metropolis-Hastings chains but, of course, the proposal │ │ │ distribution for a given walker depends on the positions of all │ │ │ the other walkers in the ensemble.’ - from the emcee webpage.
│ │ │ -burn (int, optional) – Discard this many samples from the start of the sampling regime.
│ │ │ -thin (int, optional) – Only accept 1 in every thin samples.
│ │ │ -ntemps (int, deprecated) – ntemps has no effect.
│ │ │ -pos (numpy.ndarray, optional) – Specify the initial positions for the sampler, an ndarray of shape │ │ │ +
burn (int, optional) – Discard this many samples from the start of the sampling regime.
│ │ │ +thin (int, optional) – Only accept 1 in every thin samples.
│ │ │ +ntemps (int, deprecated) – ntemps has no effect.
│ │ │ +pos (numpy.ndarray, optional) – Specify the initial positions for the sampler, an ndarray of shape │ │ │ (nwalkers, nvarys). You can also initialise using a previous │ │ │ chain of the same nwalkers and nvarys. Note that nvarys may │ │ │ be one larger than you expect it to be if your userfcn returns │ │ │ an array and is_weighted is False.
│ │ │ -reuse_sampler (bool, optional) – Set to True if you have already run emcee with the Minimizer │ │ │ +
reuse_sampler (bool, optional) – Set to True if you have already run emcee with the Minimizer │ │ │ instance and want to continue to draw from its
sampler
(and so │ │ │ retain the chain history). If False, a new sampler is created. │ │ │ The keywords nwalkers, pos, and params will be ignored when │ │ │ this is set, as they will be set by the existing sampler. │ │ │ Important: the Parameters used to create the sampler must not │ │ │ change in-between calls to emcee. Alteration of Parameters │ │ │ would include changedmin
,max
,vary
andexpr
│ │ │ attributes. This may happen, for example, if you use an altered │ │ │ Parameters object and call the minimize method in-between calls │ │ │ to emcee.
│ │ │ -workers (Pool-like or int, optional) – For parallelization of sampling. It can be any Pool-like object │ │ │ +
workers (Pool-like or int, optional) – For parallelization of sampling. It can be any Pool-like object │ │ │ with a map method that follows the same calling sequence as the │ │ │ built-in map function. If int is given as the argument, then a │ │ │ multiprocessing-based pool is spawned internally with the │ │ │ corresponding number of parallel processes. ‘mpi4py’-based │ │ │ parallelization and ‘joblib’-based parallelization pools can also │ │ │ be used here. Note: because of multiprocessing overhead it may │ │ │ only be worth parallelising if the objective function is expensive │ │ │ to calculate, or if there are a large number of objective │ │ │ evaluations per step (nwalkers * nvarys).
│ │ │ -float_behavior (str, optional) – Meaning of float (scalar) output of objective function. Use │ │ │ +
float_behavior (str, optional) – Meaning of float (scalar) output of objective function. Use │ │ │ ‘posterior’ if it returns a log-posterior probability or ‘chi2’ │ │ │ if it returns \(\chi^2\). See Notes for further details.
│ │ │ -is_weighted (bool, optional) – Has your objective function been weighted by measurement │ │ │ +
is_weighted (bool, optional) – Has your objective function been weighted by measurement │ │ │ uncertainties? If is_weighted is True then your objective │ │ │ function is assumed to return residuals that have been divided by │ │ │ the true measurement uncertainty (data - model) / sigma. If │ │ │ is_weighted is False then the objective function is assumed to │ │ │ return unweighted residuals, data - model. In this case emcee │ │ │ will employ a positive measurement uncertainty during the sampling. │ │ │ This measurement uncertainty will be present in the output params │ │ │ @@ -1686,15 +1686,15 @@ │ │ │ function returns an array. If your objective function returns a │ │ │ float, then this parameter is ignored. See Notes for more details.
│ │ │ seed (int or numpy.random.RandomState, optional) – If seed is an int, a new numpy.random.RandomState instance is │ │ │ used, seeded with seed. │ │ │ If seed is already a numpy.random.RandomState instance, then │ │ │ that numpy.random.RandomState instance is used. │ │ │ Specify seed for repeatable minimizations.
│ │ │ -progress (bool, optional) – Print a progress bar to the console while running.
│ │ │ +progress (bool, optional) – Print a progress bar to the console while running.
│ │ │
│ │ │ - Returns │ │ │
MinimizerResult object containing updated params, statistics, │ │ │ etc. The updated params represent the median of the samples, │ │ │ while the uncertainties are half the difference of the 15.87 │ │ │ and 84.13 percentiles. The MinimizerResult contains a few │ │ ├── ./usr/share/doc/python3-lmfit/html/intro.html │ │ │ @@ -162,15 +162,15 @@ │ │ │ decay = variables[3] │ │ │ │ │ │ model = amp * sin(x*freq + phaseshift) * exp(-x*x*decay) │ │ │ │ │ │ return (data-model) / eps_data │ │ │
To perform the minimization with
│ │ │ +scipy.optimize
, one would do this:To perform the minimization with
│ │ │scipy.optimize
, one would do this:│ │ ││ │ │from scipy.optimize import leastsq │ │ │ │ │ │ variables = [10.0, 0.2, 3.0, 0.007] │ │ │ out = leastsq(residual, variables, args=(x, data, eps_data)) │ │ │
Though it is wonderful to be able to use Python for such optimization │ │ ├── ./usr/share/doc/python3-lmfit/html/model.html │ │ │ @@ -155,15 +155,15 @@ │ │ │
│ │ │ │ │ ││ │ ││ │ │Modeling Data and Curve Fitting¶
│ │ │A common use of least-squares minimization is curve fitting, where one │ │ │ has a parametrized model function meant to explain some phenomena and wants │ │ │ to adjust the numerical values for the model so that it most closely │ │ │ -matches some data. With
│ │ │ @@ -296,20 +296,20 @@ │ │ │scipy
, such problems are typically solved │ │ │ +matches some data. Withscipy
, such problems are typically solved │ │ │ with scipy.optimize.curve_fit, which is a wrapper around │ │ │ scipy.optimize.leastsq. Since lmfit’s │ │ │minimize()
is also a high-level wrapper around │ │ │ scipy.optimize.leastsq it can be used for curve-fitting problems. │ │ │ While it offers many benefits over scipy.optimize.leastsq, using │ │ │minimize()
for many curve-fitting problems still │ │ │ requires more effort than using scipy.optimize.curve_fit.-
│ │ │
- Parameters │ │ │
-
│ │ │
func (callable) – Function to be wrapped.
│ │ │ independent_vars (list of str, optional) – Arguments to func that are independent variables (default is None).
│ │ │ param_names (list of str, optional) – Names of arguments to func that are to be made into parameters │ │ │ (default is None).
│ │ │ -nan_policy (str, optional) – How to handle NaN and missing values in data. Must be one of │ │ │ +
nan_policy (str, optional) – How to handle NaN and missing values in data. Must be one of │ │ │ ‘raise’ (default), ‘propagate’, or ‘omit’. See Note below.
│ │ │ -prefix (str, optional) – Prefix used for the model.
│ │ │ -name (str, optional) – Name for the model. When None (default) the name is the same as │ │ │ +
prefix (str, optional) – Prefix used for the model.
│ │ │ +name (str, optional) – Name for the model. When None (default) the name is the same as │ │ │ the model function (func).
│ │ │ -**kws (dict, optional) – Additional keyword arguments to pass to model function.
│ │ │ +**kws (dict, optional) – Additional keyword arguments to pass to model function.
│ │ │
│ │ │
Notes
│ │ │1. Parameter names are inferred from the function arguments, │ │ │ and a residual function is automatically constructed.
│ │ │2. The model function must return an array that will be the same │ │ │ @@ -358,15 +358,15 @@ │ │ │
│ │ │ │ │ │ │ │ │**kwargs (optional) – Additional keyword arguments to pass to model function.
- Returns
│ │ │ │ │ │Value of model given the parameters and other arguments.
│ │ │- Return type
│ │ │ -- │ │ │ +
│ │ │ │ │ │- │ │ │
│ │ │ │ │ │Notes
│ │ │1. if params is None, the values for all parameters are │ │ │ expected to be provided as keyword arguments. If params is │ │ │ given, and a keyword argument for a parameter value is also given, │ │ │ the keyword argument will be used.
│ │ │ @@ -382,26 +382,26 @@ │ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
data (array_like) – Array of data to be fit.
│ │ │ params (Parameters, optional) – Parameters to use in fit (default is None).
│ │ │ weights (array_like of same size as data, optional) – Weights to use for the calculation of the fit residual (default │ │ │ is None).
│ │ │ -method (str, optional) – Name of fitting method to use (default is ‘leastsq’).
│ │ │ +method (str, optional) – Name of fitting method to use (default is ‘leastsq’).
│ │ │ iter_cb (callable, optional) – Callback function to call at each iteration (default is None).
│ │ │ -scale_covar (bool, optional) – Whether to automatically scale the covariance matrix when │ │ │ +
scale_covar (bool, optional) – Whether to automatically scale the covariance matrix when │ │ │ calculating uncertainties (default is True).
│ │ │ -verbose (bool, optional) – Whether to print a message when a new parameter is added because │ │ │ +
verbose (bool, optional) – Whether to print a message when a new parameter is added because │ │ │ of a hint (default is True).
│ │ │ -nan_policy (str, optional, one of 'raise' (default), 'propagate', or 'omit'.) – What to do when encountering NaNs when fitting Model.
│ │ │ -fit_kws (dict, optional) – Options to pass to the minimizer being used.
│ │ │ -calc_covar (bool, optional) – Whether to calculate the covariance matrix (default is True) for │ │ │ +
nan_policy (str, optional, one of 'raise' (default), 'propagate', or 'omit'.) – What to do when encountering NaNs when fitting Model.
│ │ │ +fit_kws (dict, optional) – Options to pass to the minimizer being used.
│ │ │ +calc_covar (bool, optional) – Whether to calculate the covariance matrix (default is True) for │ │ │ solvers other than leastsq and least_squares. Requires the │ │ │ numdifftools package to be installed.
│ │ │ -max_nfev (int or None, optional) – Maximum number of function evaluations (default is None). The │ │ │ +
max_nfev (int or None, optional) – Maximum number of function evaluations (default is None). The │ │ │ default value depends on the fitting method.
│ │ │ **kwargs (optional) – Arguments to pass to the model function, possibly overriding │ │ │ params.
│ │ │
│ │ │ - Returns │ │ │
- │ │ │ @@ -459,27 +459,27 @@ │ │ │
Notes
│ │ │Should be implemented for each model subclass to run │ │ │ self.make_params(), update starting values and return a │ │ │ Parameters object.
│ │ │-
│ │ │
- Raises │ │ │ -
-
│ │ │ +
- │ │ │
│ │ │
-
│ │ │
-
│ │ │
Model.
make_params
(verbose=False, **kwargs)¶
│ │ │ Create a Parameters object for a Model.
│ │ │-
│ │ │
- Parameters │ │ │
- │ │ │ │ │ │
- Returns │ │ │
params
│ │ │
│ │ │ - Return type │ │ │ @@ -501,15 +501,15 @@ │ │ │
- Parameters │ │ │
-
│ │ │ -
name (str) – Parameter name.
│ │ │ +name (str) – Parameter name.
│ │ │ **kwargs (optional) –
Arbitrary keyword arguments, needs to be a Parameter attribute. │ │ │ Can be any of the following:
│ │ │-
│ │ │
-
│ │ │
- valuefloat, optional
Numerical Parameter value.
│ │ │
│ │ │
-
│ │ │
-
│ │ │
Model.
print_param_hints
(colwidth=8)¶
│ │ │ Print a nicely aligned text-table of parameter hints.
│ │ │ │ │ │
This is especially convenient for setting initial values. The name │ │ │ can include the models prefix or not. The hint given can also │ │ │ include optional bounds and constraints
│ │ │(value, vary, min, max, expr)
, │ │ │ which will be used by make_params() when building default parameters.-
│ │ │
│ │ │
│ │ │ @@ -843,29 +843,29 @@ │ │ │Model
class Attributes¶- │ │ │
│ │ │save_model
(model, fname)¶ │ │ │ │ │ │Save a Model to a file.
│ │ │ │ │ │-
│ │ │
-
│ │ │
load_model
(fname, funcdefs=None)¶
│ │ │ Load a saved Model from a file.
│ │ │-
│ │ │
- Parameters │ │ │
- │ │ │ │ │ │
- Returns │ │ │
- │ │ │ │ │ │
- Return type │ │ │
-
│ │ │ @@ -909,24 +909,24 @@
│ │ │
-
│ │ │
- Parameters │ │ │
-
│ │ │
model (Model) – Model to use.
│ │ │ params (Parameters) – Parameters with initial values for model.
│ │ │ data (array_like, optional) – Data to be modeled.
│ │ │ weights (array_like, optional) – Weights to multiply (data-model) for fit residual.
│ │ │ -method (str, optional) – Name of minimization method to use (default is ‘leastsq’).
│ │ │ +method (str, optional) – Name of minimization method to use (default is ‘leastsq’).
│ │ │ fcn_args (sequence, optional) – Positional arguments to send to model function.
│ │ │ -fcn_dict (dict, optional) – Keyword arguments to send to model function.
│ │ │ +fcn_dict (dict, optional) – Keyword arguments to send to model function.
│ │ │ iter_cb (callable, optional) – Function to call on each iteration of fit.
│ │ │ -scale_covar (bool, optional) – Whether to scale covariance matrix for uncertainty evaluation.
│ │ │ -nan_policy (str, optional, one of 'raise' (default), 'propagate', or 'omit'.) – What to do when encountering NaNs when fitting Model.
│ │ │ -calc_covar (bool, optional) – Whether to calculate the covariance matrix (default is True) for │ │ │ +
scale_covar (bool, optional) – Whether to scale covariance matrix for uncertainty evaluation.
│ │ │ +nan_policy (str, optional, one of 'raise' (default), 'propagate', or 'omit'.) – What to do when encountering NaNs when fitting Model.
│ │ │ +calc_covar (bool, optional) – Whether to calculate the covariance matrix (default is True) for │ │ │ solvers other than leastsq and least_squares. Requires the │ │ │ numdifftools package to be installed.
│ │ │ -max_nfev (int or None, optional) – Maximum number of function evaluations (default is None). The │ │ │ +
max_nfev (int or None, optional) – Maximum number of function evaluations (default is None). The │ │ │ default value depends on the fitting method.
│ │ │ **fit_kws (optional) – Keyword arguments to send to minimization routine.
│ │ │
│ │ │
│ │ │ │ │ │**kwargs (optional) – Options to send to Model.eval()
│ │ │ - Returns │ │ │
out – Array for evaluated model.
│ │ │
│ │ │ - Return type │ │ │ -
-
│ │ │ +
- │ │ │
│ │ │
-
│ │ │
-
│ │ │
ModelResult.
eval_components
(params=None, **kwargs)¶
│ │ │ @@ -979,16 +979,16 @@
│ │ │ Re-perform fit for a Model, given data and params.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
data (array_like, optional) – Data to be modeled.
│ │ │ params (Parameters, optional) – Parameters with initial values for model.
│ │ │ weights (array_like, optional) – Weights to multiply (data-model) for fit residual.
│ │ │ -method (str, optional) – Name of minimization method to use (default is ‘leastsq’).
│ │ │ -nan_policy (str, optional, one of 'raise' (default), 'propagate', or 'omit'.) – What to do when encountering NaNs when fitting Model.
│ │ │ +method (str, optional) – Name of minimization method to use (default is ‘leastsq’).
│ │ │ +nan_policy (str, optional, one of 'raise' (default), 'propagate', or 'omit'.) – What to do when encountering NaNs when fitting Model.
│ │ │ **kwargs (optional) – Keyword arguments to send to minimization routine.
│ │ │
│ │ │
-
│ │ │ @@ -997,28 +997,28 @@
│ │ │
Return a printable fit report.
│ │ │The report contains fit statistics and best-fit values with │ │ │ uncertainties and correlations.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
modelpars (Parameters, optional) – Known Model Parameters.
│ │ │ -show_correl (bool, optional) – Whether to show list of sorted correlations (default is True).
│ │ │ -min_correl (float, optional) – Smallest correlation in absolute value to show (default is 0.1).
│ │ │ +show_correl (bool, optional) – Whether to show list of sorted correlations (default is True).
│ │ │ +min_correl (float, optional) – Smallest correlation in absolute value to show (default is 0.1).
│ │ │ sort_pars (callable, optional) – Whether to show parameter names sorted in alphanumerical order │ │ │ (default is False). If False, then the parameters will be listed in │ │ │ the order as they were added to the Parameters dictionary. If callable, │ │ │ then this (one argument) function is used to extract a comparison key │ │ │ from each list element.
│ │ │
│ │ │ - Returns │ │ │
text – Multi-line text of fit report.
│ │ │
│ │ │ - Return type │ │ │ -
-
│ │ │ +
- │ │ │
│ │ │
│ │ ││ │ │See also
│ │ │ │ │ │
-
│ │ │
-
│ │ │
ModelResult.
ci_report
(with_offset=True, ndigits=5, **kwargs)¶
│ │ │ Return a nicely formatted text report of the confidence intervals.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │ -
with_offset (bool, optional) – Whether to subtract best value from all other values (default is True).
│ │ │ -ndigits (int, optional) – Number of significant digits to show (default is 5).
│ │ │ +with_offset (bool, optional) – Whether to subtract best value from all other values (default is True).
│ │ │ +ndigits (int, optional) – Number of significant digits to show (default is 5).
│ │ │ **kwargs (optional) – Keyword arguments that are passed to the conf_interval function.
│ │ │
│ │ │ - Returns │ │ │
Text of formatted report on confidence intervals.
│ │ │
│ │ │ - Return type │ │ │ -
-
│ │ │ +
- │ │ │
│ │ │
-
│ │ │
-
│ │ │
ModelResult.
eval_uncertainty
(params=None, sigma=1, **kwargs)¶
│ │ │ Evaluate the uncertainty of the model function.
│ │ │This can be used to give confidence bands for the model from the │ │ │ uncertainties in the best-fit parameters.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │
params (Parameters, optional) – Parameters, defaults to ModelResult.params.
│ │ │ -sigma (float, optional) – Confidence level, i.e. how many sigma (default is 1).
│ │ │ +sigma (float, optional) – Confidence level, i.e. how many sigma (default is 1).
│ │ │ **kwargs (optional) – Values of options, independent variables, etcetera.
│ │ │
│ │ │ - Returns │ │ │
Uncertainty at each value of the model.
│ │ │
│ │ │ - Return type │ │ │ -
-
│ │ │ +
- │ │ │
│ │ │
Example
│ │ │>>> out = model.fit(data, params, x=x) │ │ │ >>> dely = out.eval_uncertainty(x=x) │ │ │ >>> plt.plot(x, data) │ │ │ >>> plt.plot(x, out.best_fit) │ │ │ @@ -1106,34 +1106,34 @@ │ │ │
The method will produce a matplotlib figure with both results of the │ │ │ fit and the residuals plotted. If the fit model included weights, │ │ │ errorbars will also be plotted. To show the initial conditions for the │ │ │ fit, pass the argument show_init=True.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │ -
datafmt (str, optional) – Matplotlib format string for data points.
│ │ │ -fitfmt (str, optional) – Matplotlib format string for fitted curve.
│ │ │ -initfmt (str, optional) – Matplotlib format string for initial conditions for the fit.
│ │ │ -xlabel (str, optional) – Matplotlib format string for labeling the x-axis.
│ │ │ -ylabel (str, optional) – Matplotlib format string for labeling the y-axis.
│ │ │ -yerr (numpy.ndarray, optional) – Array of uncertainties for data array.
│ │ │ -numpoints (int, optional) – If provided, the final and initial fit curves are evaluated not │ │ │ +
datafmt (str, optional) – Matplotlib format string for data points.
│ │ │ +fitfmt (str, optional) – Matplotlib format string for fitted curve.
│ │ │ +initfmt (str, optional) – Matplotlib format string for initial conditions for the fit.
│ │ │ +xlabel (str, optional) – Matplotlib format string for labeling the x-axis.
│ │ │ +ylabel (str, optional) – Matplotlib format string for labeling the y-axis.
│ │ │ +yerr (numpy.ndarray, optional) – Array of uncertainties for data array.
│ │ │ +numpoints (int, optional) – If provided, the final and initial fit curves are evaluated not │ │ │ only at data points, but refined to contain numpoints points in │ │ │ total.
│ │ │ fig (matplotlib.figure.Figure, optional) – The figure to plot on. The default is None, which means use the │ │ │ current pyplot figure or create one if there is none.
│ │ │ -data_kws (dict, optional) – Keyword arguments passed on to the plot function for data points.
│ │ │ -fit_kws (dict, optional) – Keyword arguments passed on to the plot function for fitted curve.
│ │ │ -init_kws (dict, optional) – Keyword arguments passed on to the plot function for the initial │ │ │ +
data_kws (dict, optional) – Keyword arguments passed on to the plot function for data points.
│ │ │ +fit_kws (dict, optional) – Keyword arguments passed on to the plot function for fitted curve.
│ │ │ +init_kws (dict, optional) – Keyword arguments passed on to the plot function for the initial │ │ │ conditions of the fit.
│ │ │ -ax_res_kws (dict, optional) – Keyword arguments for the axes for the residuals plot.
│ │ │ -ax_fit_kws (dict, optional) – Keyword arguments for the axes for the fit plot.
│ │ │ -fig_kws (dict, optional) – Keyword arguments for a new figure, if there is one being created.
│ │ │ -show_init (bool, optional) – Whether to show the initial conditions for the fit (default is False).
│ │ │ -parse_complex (str, optional) – How to reduce complex data for plotting. │ │ │ +
ax_res_kws (dict, optional) – Keyword arguments for the axes for the residuals plot.
│ │ │ +ax_fit_kws (dict, optional) – Keyword arguments for the axes for the fit plot.
│ │ │ +fig_kws (dict, optional) – Keyword arguments for a new figure, if there is one being created.
│ │ │ +show_init (bool, optional) – Whether to show the initial conditions for the fit (default is False).
│ │ │ +parse_complex (str, optional) – How to reduce complex data for plotting. │ │ │ Options are one of [‘real’, ‘imag’, ‘abs’, ‘angle’], which │ │ │ correspond to the numpy functions of the same name (default is ‘abs’).
│ │ │
│ │ │ - Returns │ │ │
- │ │ │ │ │ │ @@ -1170,30 +1170,30 @@ │ │ │ included weights or if yerr is specified, errorbars will also be │ │ │ plotted. │ │ │
- Parameters │ │ │
-
│ │ │
ax (matplotlib.axes.Axes, optional) – The axes to plot on. The default in None, which means use the │ │ │ current pyplot axis or create one if there is none.
│ │ │ -datafmt (str, optional) – Matplotlib format string for data points.
│ │ │ -fitfmt (str, optional) – Matplotlib format string for fitted curve.
│ │ │ -initfmt (str, optional) – Matplotlib format string for initial conditions for the fit.
│ │ │ -xlabel (str, optional) – Matplotlib format string for labeling the x-axis.
│ │ │ -ylabel (str, optional) – Matplotlib format string for labeling the y-axis.
│ │ │ -yerr (numpy.ndarray, optional) – Array of uncertainties for data array.
│ │ │ -numpoints (int, optional) – If provided, the final and initial fit curves are evaluated not │ │ │ +
datafmt (str, optional) – Matplotlib format string for data points.
│ │ │ +fitfmt (str, optional) – Matplotlib format string for fitted curve.
│ │ │ +initfmt (str, optional) – Matplotlib format string for initial conditions for the fit.
│ │ │ +xlabel (str, optional) – Matplotlib format string for labeling the x-axis.
│ │ │ +ylabel (str, optional) – Matplotlib format string for labeling the y-axis.
│ │ │ +yerr (numpy.ndarray, optional) – Array of uncertainties for data array.
│ │ │ +numpoints (int, optional) – If provided, the final and initial fit curves are evaluated not │ │ │ only at data points, but refined to contain numpoints points in │ │ │ total.
│ │ │ -data_kws (dict, optional) – Keyword arguments passed on to the plot function for data points.
│ │ │ -fit_kws (dict, optional) – Keyword arguments passed on to the plot function for fitted curve.
│ │ │ -init_kws (dict, optional) – Keyword arguments passed on to the plot function for the initial │ │ │ +
data_kws (dict, optional) – Keyword arguments passed on to the plot function for data points.
│ │ │ +fit_kws (dict, optional) – Keyword arguments passed on to the plot function for fitted curve.
│ │ │ +init_kws (dict, optional) – Keyword arguments passed on to the plot function for the initial │ │ │ conditions of the fit.
│ │ │ -ax_kws (dict, optional) – Keyword arguments for a new axis, if there is one being created.
│ │ │ -show_init (bool, optional) – Whether to show the initial conditions for the fit (default is False).
│ │ │ -parse_complex (str, optional) – How to reduce complex data for plotting. │ │ │ +
ax_kws (dict, optional) – Keyword arguments for a new axis, if there is one being created.
│ │ │ +show_init (bool, optional) – Whether to show the initial conditions for the fit (default is False).
│ │ │ +parse_complex (str, optional) – How to reduce complex data for plotting. │ │ │ Options are one of [‘real’, ‘imag’, ‘abs’, ‘angle’], which │ │ │ correspond to the numpy functions of the same name (default is ‘abs’).
│ │ │
│ │ │ - Returns │ │ │
- │ │ │ │ │ │ @@ -1228,20 +1228,20 @@ │ │ │
- Parameters │ │ │
-
│ │ │
ax (matplotlib.axes.Axes, optional) – The axes to plot on. The default in None, which means use the │ │ │ current pyplot axis or create one if there is none.
│ │ │ -datafmt (str, optional) – Matplotlib format string for data points.
│ │ │ -yerr (numpy.ndarray, optional) – Array of uncertainties for data array.
│ │ │ -data_kws (dict, optional) – Keyword arguments passed on to the plot function for data points.
│ │ │ -fit_kws (dict, optional) – Keyword arguments passed on to the plot function for fitted curve.
│ │ │ -ax_kws (dict, optional) – Keyword arguments for a new axis, if there is one being created.
│ │ │ -parse_complex (str, optional) – How to reduce complex data for plotting. │ │ │ +
datafmt (str, optional) – Matplotlib format string for data points.
│ │ │ +yerr (numpy.ndarray, optional) – Array of uncertainties for data array.
│ │ │ +data_kws (dict, optional) – Keyword arguments passed on to the plot function for data points.
│ │ │ +fit_kws (dict, optional) – Keyword arguments passed on to the plot function for fitted curve.
│ │ │ +ax_kws (dict, optional) – Keyword arguments for a new axis, if there is one being created.
│ │ │ +parse_complex (str, optional) – How to reduce complex data for plotting. │ │ │ Options are one of [‘real’, ‘imag’, ‘abs’, ‘angle’], which │ │ │ correspond to the numpy functions of the same name (default is ‘abs’).
│ │ │
│ │ │ - Returns │ │ │
- │ │ │ │ │ │ @@ -1497,29 +1497,29 @@ │ │ │
-
│ │ │
save_modelresult
(modelresult, fname)¶
│ │ │ Save a ModelResult to a file.
│ │ │ │ │ │-
│ │ │
load_modelresult
(fname, funcdefs=None)¶
│ │ │ Load a saved ModelResult from a file.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │ -
fname (str) – Name of file containing saved ModelResult.
│ │ │ -funcdefs (dict, optional) – Dictionary of custom function names and definitions.
│ │ │ +fname (str) – Name of file containing saved ModelResult.
│ │ │ +funcdefs (dict, optional) – Dictionary of custom function names and definitions.
│ │ │
│ │ │ - Returns │ │ │
- │ │ │ │ │ │
- Return type │ │ │
-
│ │ ├── ./usr/share/doc/python3-lmfit/html/parameters.html
│ │ │ @@ -132,29 +132,29 @@
│ │ │
│ │ │ │ │ │
│ │ │Parameter
andParameters
¶This chapter describes the
│ │ │Parameter
object, which is a key concept of │ │ │ lmfit.A
│ │ │Parameter
is the quantity to be optimized in all minimization │ │ │ problems, replacing the plain floating point number used in the │ │ │ -optimization routines fromscipy.optimize
. AParameter
has │ │ │ +optimization routines fromscipy.optimize
. AParameter
has │ │ │ a value that can either be varied in the fit or held at a fixed value, and │ │ │ can have upper and/or lower bounds placed on the value. It can even have a │ │ │ value that is constrained by an algebraic expression of other Parameter │ │ │ values. SinceParameter
objects live outside the core │ │ │ optimization routines, they can be used in all optimization routines │ │ │ -fromscipy.optimize
. By usingParameter
objects instead of │ │ │ +fromscipy.optimize
. By usingParameter
objects instead of │ │ │ plain variables, the objective function does not have to be modified to │ │ │ reflect every change of what is varied in the fit, or whether bounds can be │ │ │ applied. This simplifies the writing of models, allowing general models │ │ │ that describe the phenomenon and gives the user more flexibility in using │ │ │ and testing variations of that model.Whereas a
Parameter
expands on an individual floating point │ │ │ variable, the optimization methods actually still need an ordered group of │ │ │ -floating point variables. In thescipy.optimize
routines this is │ │ │ +floating point variables. In thescipy.optimize
routines this is │ │ │ required to be a one-dimensional numpy.ndarray. In lmfit, this one-dimensional │ │ │ array is replaced by aParameters
object, which works as an │ │ │ ordered dictionary ofParameter
objects with a few additional │ │ │ features and methods. That is, while the concept of aParameter
│ │ │ is central to lmfit, one normally creates and interacts with a │ │ │Parameters
instance that contains manyParameter
objects. │ │ │ For example, the objective functions you write for lmfit will take an │ │ │ @@ -181,47 +181,47 @@ │ │ │After a minimization, a Parameter may also gain other attributes, │ │ │ including stderr holding the estimated standard error in the │ │ │ Parameter’s value, and correl, a dictionary of correlation values │ │ │ with other Parameters used in the minimization.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │ -
name (str) – Name of the Parameter.
│ │ │ -value (float, optional) – Numerical Parameter value.
│ │ │ -vary (bool, optional) – Whether the Parameter is varied during a fit (default is True).
│ │ │ -min (float, optional) – Lower bound for value (default is -numpy.inf, no lower bound).
│ │ │ -max (float, optional) – Upper bound for value (default is numpy.inf, no upper bound).
│ │ │ -expr (str, optional) – Mathematical expression used to constrain the value during the fit.
│ │ │ -brute_step (float, optional) – Step size for grid points in the brute method.
│ │ │ +name (str) – Name of the Parameter.
│ │ │ +value (float, optional) – Numerical Parameter value.
│ │ │ +vary (bool, optional) – Whether the Parameter is varied during a fit (default is True).
│ │ │ +min (float, optional) – Lower bound for value (default is -numpy.inf, no lower bound).
│ │ │ +max (float, optional) – Upper bound for value (default is numpy.inf, no upper bound).
│ │ │ +expr (str, optional) – Mathematical expression used to constrain the value during the fit.
│ │ │ +brute_step (float, optional) – Step size for grid points in the brute method.
│ │ │ user_data (optional) – User-definable extra attribute used for a Parameter.
│ │ │
│ │ │
-
│ │ │
-
│ │ │
stderr
¶
│ │ │ The estimated standard error for the best-fit value.
│ │ │ │ │ │
-
│ │ │
-
│ │ │
correl
¶
│ │ │ A dictionary of the correlation with the other fitted Parameters │ │ │ of the form:
│ │ ││ │ │ │ │ ││ │ │`{'decay': 0.404, 'phase': -0.020, 'frequency': 0.102}` │ │ │
See Bounds Implementation for details on the math used to implement the │ │ │ bounds with
│ │ │min
andmax
.The
expr
attribute can contain a mathematical expression that will │ │ │ @@ -231,23 +231,23 @@ │ │ │-
│ │ │
-
│ │ │
set
(value=None, vary=None, min=None, max=None, expr=None, brute_step=None)¶
│ │ │ Set or update Parameter attributes.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │ -
value (float, optional) – Numerical Parameter value.
│ │ │ -vary (bool, optional) – Whether the Parameter is varied during a fit.
│ │ │ -min (float, optional) – Lower bound for value. To remove a lower bound you must use │ │ │ +
value (float, optional) – Numerical Parameter value.
│ │ │ +vary (bool, optional) – Whether the Parameter is varied during a fit.
│ │ │ +min (float, optional) – Lower bound for value. To remove a lower bound you must use │ │ │ -numpy.inf.
│ │ │ -max (float, optional) – Upper bound for value. To remove an upper bound you must use │ │ │ +
max (float, optional) – Upper bound for value. To remove an upper bound you must use │ │ │ numpy.inf.
│ │ │ -expr (str, optional) – Mathematical expression used to constrain the value during the fit. │ │ │ +
expr (str, optional) – Mathematical expression used to constrain the value during the fit. │ │ │ To remove a constraint you must supply an empty string.
│ │ │ -brute_step (float, optional) – Step size for grid points in the brute method. To remove the │ │ │ +
brute_step (float, optional) – Step size for grid points in the brute method. To remove the │ │ │ step size you must use
0
.
│ │ │
│ │ │
Notes
│ │ │Each argument to set() has a default value of None, which will │ │ │ leave the current value for the attribute unchanged. Thus, to lift a │ │ │ @@ -307,22 +307,22 @@ │ │ │
-
│ │ │
-
│ │ │
add
(name, value=None, vary=True, min=- inf, max=inf, expr=None, brute_step=None)¶
│ │ │ Add a Parameter.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │ -
name (str) – Name of parameter. Must match
[a-z_][a-z0-9_]*
and cannot be │ │ │ +name (str) – Name of parameter. Must match
[a-z_][a-z0-9_]*
and cannot be │ │ │ a Python reserved word.
│ │ │ -value (float, optional) – Numerical Parameter value, typically the initial value.
│ │ │ -vary (bool, optional) – Whether the Parameter is varied during a fit (default is True).
│ │ │ -min (float, optional) – Lower bound for value (default is -numpy.inf, no lower bound).
│ │ │ -max (float, optional) – Upper bound for value (default is numpy.inf, no upper bound).
│ │ │ -expr (str, optional) – Mathematical expression used to constrain the value during the fit.
│ │ │ -brute_step (float, optional) – Step size for grid points in the brute method.
│ │ │ +value (float, optional) – Numerical Parameter value, typically the initial value.
│ │ │ +vary (bool, optional) – Whether the Parameter is varied during a fit (default is True).
│ │ │ +min (float, optional) – Lower bound for value (default is -numpy.inf, no lower bound).
│ │ │ +max (float, optional) – Upper bound for value (default is numpy.inf, no upper bound).
│ │ │ +expr (str, optional) – Mathematical expression used to constrain the value during the fit.
│ │ │ +brute_step (float, optional) – Step size for grid points in the brute method.
│ │ │
│ │ │
Examples
│ │ │>>> params = Parameters() │ │ │ >>> params.add('xvar', value=0.50, min=0, max=1) │ │ │ >>> params.add('yvar', expr='1.0 - xvar') │ │ │ @@ -338,15 +338,15 @@ │ │ │ │ │ │
-
│ │ │
-
│ │ │
add_many
(*parlist)¶
│ │ │ Add many parameters, using a sequence of tuples.
│ │ │-
│ │ │
- Parameters │ │ │ -
parlist (
sequence
oftuple
orParameter
) – A sequence of tuples, or a sequence of Parameter instances. If │ │ │ + │ │ │parlist (
│ │ │sequence
oftuple
orParameter
) – A sequence of tuples, or a sequence of Parameter instances. If │ │ │ it is a sequence of tuples, then each tuple must contain at least │ │ │ the name. The order in each tuple must be (name, value, vary, │ │ │ min, max, expr, brute_step).
Examples
│ │ ││ │ │>>> params = Parameters() │ │ │ @@ -366,21 +366,21 @@ │ │ │
-
│ │ │
-
│ │ │
pretty_print
(oneline=False, colwidth=8, precision=4, fmt='g', columns=['value', 'min', 'max', 'stderr', 'vary', 'expr', 'brute_step'])¶
│ │ │ Pretty-print of parameters data.
│ │ │-
│ │ │
- Parameters │ │ │
-
│ │ │ -
oneline (bool, optional) – If True prints a one-line parameters representation (default is │ │ │ +
oneline (bool, optional) – If True prints a one-line parameters representation (default is │ │ │ False).
│ │ │ -colwidth (int, optional) – Column width for all columns specified in
columns
.
│ │ │ -precision (int, optional) – Number of digits to be printed after floating point.
│ │ │ +colwidth (int, optional) – Column width for all columns specified in
columns
.
│ │ │ +precision (int, optional) – Number of digits to be printed after floating point.
│ │ │ fmt ({'g', 'e', 'f'}, optional) – Single-character numeric formatter. Valid values are: ‘f’ floating │ │ │ point, ‘g’ floating point and exponential, or ‘e’ exponential.
│ │ │ -columns (
list
ofstr
, optional) – List ofParameter
attribute names to print.
│ │ │ +columns (
list
ofstr
, optional) – List ofParameter
attribute names to print.
│ │ │
│ │ │
-
│ │ │
-
│ │ │ @@ -405,20 +405,20 @@
│ │ │
- Parameters
│ │ │ **kws (optional) – Keyword arguments that are passed to json.dumps().
│ │ │
│ │ │ - Returns │ │ │
JSON string representation of Parameters.
│ │ │
│ │ │ - Return type │ │ │ -
-
│ │ │ +
- │ │ │
│ │ │
-
│ │ │
-
│ │ │
dump
(fp, **kws)¶
│ │ │ Write JSON representation of Parameters to a file-like object.
│ │ │ @@ -429,20 +429,20 @@ │ │ │ │ │ │ │ │ │**kws (optional) – Keyword arguments that are passed to dumps().
│ │ │ - Returns │ │ │
Return value from fp.write(): the number of characters written.
│ │ │
│ │ │ - Return type │ │ │ -
-
│ │ │ +
- │ │ │
│ │ │
-
│ │ │
-
│ │ │
eval
(expr)¶
│ │ │ Evaluate a statement using the asteval Interpreter.
│ │ │ @@ -476,15 +476,15 @@ │ │ │
│ │ │
Notes
│ │ │Current Parameters will be cleared before loading the data from the │ │ │ JSON string.
│ │ │ │ │ │ │ │ │ │ │ │-
│ │ │
-
│ │ │
load
(fp, **kws)¶
│ │ │ Load JSON representation of Parameters from a file-like object.
│ │ │ @@ -500,15 +500,15 @@ │ │ │
│ │ │ - Return type │ │ │
- │ │ │ │ │ │
│ │ ├── ./usr/share/doc/python3-lmfit/html/searchindex.js │ │ │ ├── js-beautify {} │ │ │ │ @@ -214,34 +214,34 @@ │ │ │ │ "00012": 8, │ │ │ │ "001": 3, │ │ │ │ "00133040": 12, │ │ │ │ "00141148": 12, │ │ │ │ "00142452": 12, │ │ │ │ "00143924": 12, │ │ │ │ "00170178": 13, │ │ │ │ - "00247237": 12, │ │ │ │ + "00247235": 12, │ │ │ │ "00247383": 5, │ │ │ │ "00270": 8, │ │ │ │ "00270400": 8, │ │ │ │ "00271542": 12, │ │ │ │ - "00311360": 5, │ │ │ │ + "00311361": 5, │ │ │ │ "00316225": 6, │ │ │ │ "00323088": 6, │ │ │ │ "00327315": 16, │ │ │ │ "00334614": 16, │ │ │ │ "0035": 7, │ │ │ │ "00353535353536": 7, │ │ │ │ "00353535354105": 7, │ │ │ │ "00481740": 8, │ │ │ │ "00482": 8, │ │ │ │ "00483": 8, │ │ │ │ + "00497508": 11, │ │ │ │ "005": 6, │ │ │ │ "00537": 8, │ │ │ │ "00539": 8, │ │ │ │ - "00566306": 11, │ │ │ │ "00590168": 9, │ │ │ │ "006e": 7, │ │ │ │ "007": 26, │ │ │ │ "00815": 8, │ │ │ │ "00819": 8, │ │ │ │ "00965": 8, │ │ │ │ "00966": 8, │ │ │ │ @@ -250,30 +250,30 @@ │ │ │ │ "00993244": 8, │ │ │ │ "00996351": 14, │ │ │ │ "010": 8, │ │ │ │ "01000": 14, │ │ │ │ "01004618": 16, │ │ │ │ "01066173": 16, │ │ │ │ "011": 5, │ │ │ │ - "011354296357346": 5, │ │ │ │ - "01135430": 5, │ │ │ │ + "01135429": 5, │ │ │ │ + "0113542941561198": 5, │ │ │ │ "01135441": 5, │ │ │ │ "01162984": 13, │ │ │ │ "01170853": 13, │ │ │ │ - "01416176": 14, │ │ │ │ + "01416175": 14, │ │ │ │ "01447": 8, │ │ │ │ "01450": 8, │ │ │ │ "01835869": 18, │ │ │ │ + "01839369": 11, │ │ │ │ "020": 28, │ │ │ │ - "02005972": 17, │ │ │ │ + "02005932": 17, │ │ │ │ "02079710": 10, │ │ │ │ "021": 13, │ │ │ │ "02341706": 13, │ │ │ │ "02384778": 12, │ │ │ │ - "02388884": 11, │ │ │ │ "02414209": 14, │ │ │ │ "02448064": 13, │ │ │ │ "02466565": 12, │ │ │ │ "02469084": 12, │ │ │ │ "02471391": 12, │ │ │ │ "02487197": 12, │ │ │ │ "025": 6, │ │ │ │ @@ -284,16 +284,16 @@ │ │ │ │ "0306e": 8, │ │ │ │ "03297": 7, │ │ │ │ "03658367": 6, │ │ │ │ "0378e": 7, │ │ │ │ "03805940": 6, │ │ │ │ "038e": 7, │ │ │ │ "04018642": 6, │ │ │ │ - "04073317": 10, │ │ │ │ - "04128604": 13, │ │ │ │ + "04073302": 10, │ │ │ │ + "04128588": 13, │ │ │ │ "04292226": 5, │ │ │ │ "04719755": 6, │ │ │ │ "04735921": 10, │ │ │ │ "04872": 8, │ │ │ │ "04884": 8, │ │ │ │ "04886345": 8, │ │ │ │ "05000000e": 6, │ │ │ │ @@ -303,73 +303,75 @@ │ │ │ │ "06087255": 12, │ │ │ │ "0625": 6, │ │ │ │ "06590577": 5, │ │ │ │ "06599962": 5, │ │ │ │ "066": 5, │ │ │ │ "06600023": 5, │ │ │ │ "0737250": 18, │ │ │ │ - "077": [15, 21], │ │ │ │ "08533642": 7, │ │ │ │ "08844670": 5, │ │ │ │ "08844674": 5, │ │ │ │ "08845": 5, │ │ │ │ "08886695": 5, │ │ │ │ "08937623": 9, │ │ │ │ + "090": [10, 21], │ │ │ │ "09162988": 6, │ │ │ │ "09473422": 5, │ │ │ │ "09762": 8, │ │ │ │ "09794": 8, │ │ │ │ - "0x7fe37c92cc10": 6, │ │ │ │ - "0x7fe37d0c61c0": 9, │ │ │ │ - "0x7fe37d10b3d0": 6, │ │ │ │ + "0x7f5919fa44c0": 6, │ │ │ │ + "0x7f591a33d7c0": 6, │ │ │ │ + "0x7f591a9381c0": 9, │ │ │ │ "100": [3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18, 20, 23, 27, 28], │ │ │ │ "1000": [5, 23], │ │ │ │ "10000": 7, │ │ │ │ "1001440": 17, │ │ │ │ "10059": 7, │ │ │ │ - "101": [6, 10, 12, 13, 17, 18, 21], │ │ │ │ + "101": [6, 10, 12, 17, 18], │ │ │ │ "102": 28, │ │ │ │ "103": 17, │ │ │ │ - "10392445": 17, │ │ │ │ + "10392444": 17, │ │ │ │ "10496394": 16, │ │ │ │ "106": [6, 12], │ │ │ │ - "107": [12, 14, 17, 21], │ │ │ │ + "107": [12, 17], │ │ │ │ "108": 12, │ │ │ │ + "10956": 11, │ │ │ │ "110": 6, │ │ │ │ "1108": 7, │ │ │ │ - "11125925": 13, │ │ │ │ + "11125922": 13, │ │ │ │ "11301": 14, │ │ │ │ "115": 6, │ │ │ │ "11813": 22, │ │ │ │ "119": 6, │ │ │ │ "120": 13, │ │ │ │ "121": 6, │ │ │ │ "12157": 8, │ │ │ │ "12157166": 8, │ │ │ │ "12172740": 5, │ │ │ │ "12228516": 5, │ │ │ │ "123": [7, 8], │ │ │ │ "12345": 14, │ │ │ │ - "124": [6, 12, 21], │ │ │ │ - "12464471": 14, │ │ │ │ + "124": 6, │ │ │ │ + "12464470": 14, │ │ │ │ "12499965": 6, │ │ │ │ "12499997": 6, │ │ │ │ "125": 6, │ │ │ │ "1262": 8, │ │ │ │ "129": 6, │ │ │ │ - "130": [9, 17, 21], │ │ │ │ + "130": [9, 17], │ │ │ │ "13089969": 6, │ │ │ │ "1309": 6, │ │ │ │ "1324": 1, │ │ │ │ "133": 7, │ │ │ │ "13340536": 18, │ │ │ │ "1338": 9, │ │ │ │ "134": 6, │ │ │ │ - "135": [1, 17], │ │ │ │ + "135": 1, │ │ │ │ "136": 10, │ │ │ │ + "137": [6, 21], │ │ │ │ "1415926": 3, │ │ │ │ "142": 7, │ │ │ │ "1425": 10, │ │ │ │ "1436": 1, │ │ │ │ "146": 10, │ │ │ │ "14659": 8, │ │ │ │ "14702": 8, │ │ │ │ @@ -378,78 +380,75 @@ │ │ │ │ "1530": 7, │ │ │ │ "1530829": 18, │ │ │ │ "1543": 7, │ │ │ │ "155": 16, │ │ │ │ "15503893": 18, │ │ │ │ "15885172": 12, │ │ │ │ "165": 16, │ │ │ │ - "166": [11, 21], │ │ │ │ "1674767": 17, │ │ │ │ "1675": 8, │ │ │ │ "1699": 8, │ │ │ │ "17160472": 18, │ │ │ │ "174": 13, │ │ │ │ - "175": [1, 16, 21], │ │ │ │ + "175": 1, │ │ │ │ "17809725": 6, │ │ │ │ - "1800": 11, │ │ │ │ - "1810": 11, │ │ │ │ - "183": 13, │ │ │ │ + "183": [9, 13, 21], │ │ │ │ + "1853": 11, │ │ │ │ + "1863": 11, │ │ │ │ "18749997": 6, │ │ │ │ "1875": 6, │ │ │ │ "18756": 14, │ │ │ │ - "1877707": 13, │ │ │ │ + "1877703": 13, │ │ │ │ "189": 12, │ │ │ │ - "192": [5, 6, 18, 21], │ │ │ │ + "192": [6, 18], │ │ │ │ "194": 16, │ │ │ │ "19401987": 10, │ │ │ │ "1946": 15, │ │ │ │ "199": 6, │ │ │ │ + "19965": 11, │ │ │ │ "1e6": 23, │ │ │ │ "1e7": 23, │ │ │ │ "200": [1, 2, 5, 7, 8, 12, 18, 20, 27], │ │ │ │ "2000": 23, │ │ │ │ "2001": 25, │ │ │ │ "2002": 25, │ │ │ │ "2003": 25, │ │ │ │ "2006": [25, 27], │ │ │ │ "201": [11, 27], │ │ │ │ "2014": [2, 23], │ │ │ │ "2019": 25, │ │ │ │ "2020": 25, │ │ │ │ "20417043e": 6, │ │ │ │ - "2065e": 11, │ │ │ │ "207": 6, │ │ │ │ "208": 6, │ │ │ │ - "20925847": 13, │ │ │ │ + "20925846": 13, │ │ │ │ "20al": 23, │ │ │ │ "20amp": 23, │ │ │ │ "20constrain": 23, │ │ │ │ "20et": 23, │ │ │ │ "20for": 23, │ │ │ │ "20global": 23, │ │ │ │ "20lasdon": 23, │ │ │ │ "20opt": 23, │ │ │ │ "20pub": 23, │ │ │ │ "20w": 23, │ │ │ │ "21434950": 16, │ │ │ │ "216": 6, │ │ │ │ "220446049250313e": 18, │ │ │ │ - "223": [7, 21], │ │ │ │ "22379520": 18, │ │ │ │ "224": 6, │ │ │ │ "22470288": 10, │ │ │ │ "225": 6, │ │ │ │ "234": 6, │ │ │ │ - "235": [18, 21], │ │ │ │ "23505243": 12, │ │ │ │ "242": 6, │ │ │ │ "24412384": 14, │ │ │ │ "247": 7, │ │ │ │ "2474265369565": 7, │ │ │ │ - "24899891": 5, │ │ │ │ + "24899892": 5, │ │ │ │ "24975620": 5, │ │ │ │ "24998843": 6, │ │ │ │ "24999772": 6, │ │ │ │ "24999999": 6, │ │ │ │ "250": [8, 14, 17, 20], │ │ │ │ "2500": 8, │ │ │ │ "25902": 8, │ │ │ │ @@ -458,18 +457,21 @@ │ │ │ │ "26503": 13, │ │ │ │ "268": 9, │ │ │ │ "26968212": 5, │ │ │ │ "27096733": 12, │ │ │ │ "2722837": 16, │ │ │ │ "276": 16, │ │ │ │ "27s_t": 1, │ │ │ │ + "280": [15, 21], │ │ │ │ "2887": 13, │ │ │ │ + "2897e": 11, │ │ │ │ "2913": 13, │ │ │ │ "294763": 7, │ │ │ │ "295": 16, │ │ │ │ + "299": [14, 21], │ │ │ │ "29975266": 12, │ │ │ │ "2_0": 2, │ │ │ │ "2_f": 2, │ │ │ │ "2jq": 7, │ │ │ │ "300": [15, 20, 30], │ │ │ │ "3001": 27, │ │ │ │ "301": 6, │ │ │ │ @@ -482,79 +484,85 @@ │ │ │ │ "31007785": 18, │ │ │ │ "3117": 7, │ │ │ │ "31249964": 6, │ │ │ │ "314": 12, │ │ │ │ "3146": 7, │ │ │ │ "317": 12, │ │ │ │ "3183099": 18, │ │ │ │ + "319": [16, 21], │ │ │ │ "320": 12, │ │ │ │ - "32191819": 13, │ │ │ │ - "33054985": 5, │ │ │ │ + "32191821": 13, │ │ │ │ + "33054984": 5, │ │ │ │ "33062": 8, │ │ │ │ "33062319": 8, │ │ │ │ "33162347": 17, │ │ │ │ "337": 12, │ │ │ │ "344": 16, │ │ │ │ "34458": 9, │ │ │ │ - "345": 21, │ │ │ │ - "34544468": 17, │ │ │ │ + "34544486": 17, │ │ │ │ + "346": [8, 21], │ │ │ │ + "349": [13, 21], │ │ │ │ "3539e": 7, │ │ │ │ "3548": [1, 27], │ │ │ │ "35769745": 12, │ │ │ │ "3646": 14, │ │ │ │ - "36481395": 13, │ │ │ │ + "36481391": 13, │ │ │ │ "375000": 6, │ │ │ │ "380": 16, │ │ │ │ "387": 13, │ │ │ │ "39269908": 6, │ │ │ │ + "400": 21, │ │ │ │ "401856": 9, │ │ │ │ - "40319891": 11, │ │ │ │ "404": 28, │ │ │ │ + "40529868": 11, │ │ │ │ "411487": 10, │ │ │ │ "412": 13, │ │ │ │ - "41260191": 13, │ │ │ │ - "414": [10, 21], │ │ │ │ + "41260369": 13, │ │ │ │ "416": 23, │ │ │ │ - "41851694": 13, │ │ │ │ + "41851692": 13, │ │ │ │ "4321": 14, │ │ │ │ "4327": 15, │ │ │ │ - "436564": 17, │ │ │ │ + "436510": 17, │ │ │ │ "43989663": 6, │ │ │ │ - "44026442": 14, │ │ │ │ + "44026441": 14, │ │ │ │ "44044": 14, │ │ │ │ "44820824": 5, │ │ │ │ "450": 10, │ │ │ │ + "452": [11, 21], │ │ │ │ + "4531e": 11, │ │ │ │ "4571e": 6, │ │ │ │ "46229147": 9, │ │ │ │ - "46253423": 5, │ │ │ │ + "46253422": 5, │ │ │ │ + "464": [17, 21], │ │ │ │ "46504191": 16, │ │ │ │ + "481": [18, 21], │ │ │ │ "486": 30, │ │ │ │ "489": 30, │ │ │ │ "491": 30, │ │ │ │ "492": 30, │ │ │ │ "4926": 7, │ │ │ │ "493": 30, │ │ │ │ "496": 30, │ │ │ │ "496119": 18, │ │ │ │ "49615727": 13, │ │ │ │ "497": 30, │ │ │ │ "499": 30, │ │ │ │ - "49989437": 11, │ │ │ │ "49999997": 6, │ │ │ │ "500": [1, 5, 15], │ │ │ │ "500000000000036": 9, │ │ │ │ "50000000e": 6, │ │ │ │ "50000055433": 7, │ │ │ │ "501": 1, │ │ │ │ + "50107103": 11, │ │ │ │ "503": 30, │ │ │ │ "504": 30, │ │ │ │ "50595764": 8, │ │ │ │ "506": 30, │ │ │ │ "507": 30, │ │ │ │ - "5081335": 17, │ │ │ │ + "5081515": 17, │ │ │ │ "5082": 7, │ │ │ │ "508878": 6, │ │ │ │ "512": 30, │ │ │ │ "51298992": 9, │ │ │ │ "514": 30, │ │ │ │ "515": 7, │ │ │ │ "517": 7, │ │ │ │ @@ -577,15 +585,15 @@ │ │ │ │ "537781821432": 7, │ │ │ │ "538": 7, │ │ │ │ "539": 30, │ │ │ │ "540": 30, │ │ │ │ "542": 30, │ │ │ │ "543": 30, │ │ │ │ "545": 30, │ │ │ │ - "547": 30, │ │ │ │ + "547": [12, 21, 30], │ │ │ │ "548": 30, │ │ │ │ "549": 30, │ │ │ │ "550": 30, │ │ │ │ "552": 30, │ │ │ │ "553": 30, │ │ │ │ "554": 30, │ │ │ │ "55438813": 14, │ │ │ │ @@ -596,15 +604,14 @@ │ │ │ │ "560626": 17, │ │ │ │ "561": 30, │ │ │ │ "5624928": 6, │ │ │ │ "5625": 6, │ │ │ │ "564": 30, │ │ │ │ "565": 30, │ │ │ │ "567": 30, │ │ │ │ - "56740": 11, │ │ │ │ "569": 30, │ │ │ │ "570": 30, │ │ │ │ "57079633": 6, │ │ │ │ "571": [6, 30], │ │ │ │ "572": 30, │ │ │ │ "573": 30, │ │ │ │ "574": 30, │ │ │ │ @@ -624,29 +631,28 @@ │ │ │ │ "593": 30, │ │ │ │ "595": 30, │ │ │ │ "596": 30, │ │ │ │ "597": 30, │ │ │ │ "598": 30, │ │ │ │ "599": 30, │ │ │ │ "600": 30, │ │ │ │ - "6003727": 13, │ │ │ │ + "6003740": 13, │ │ │ │ "601": [9, 13, 16], │ │ │ │ "6013": 1, │ │ │ │ "604": 30, │ │ │ │ - "6053e": 11, │ │ │ │ "607": 30, │ │ │ │ "608": 30, │ │ │ │ "610": 30, │ │ │ │ "611": 30, │ │ │ │ - "61125925": 13, │ │ │ │ + "61125922": 13, │ │ │ │ "612": [13, 30], │ │ │ │ "612196": 9, │ │ │ │ "614": 30, │ │ │ │ "616": 30, │ │ │ │ - "61672676": 13, │ │ │ │ + "61672675": 13, │ │ │ │ "617": 1, │ │ │ │ "619": 30, │ │ │ │ "61941": 7, │ │ │ │ "620": [16, 30], │ │ │ │ "623": [13, 30], │ │ │ │ "62389698": 18, │ │ │ │ "62499998": 6, │ │ │ │ @@ -662,71 +668,69 @@ │ │ │ │ "636": 30, │ │ │ │ "637": 30, │ │ │ │ "640x640": 5, │ │ │ │ "650757": 18, │ │ │ │ "65449847": 6, │ │ │ │ "6565773": 9, │ │ │ │ "65660": 13, │ │ │ │ - "65749": 11, │ │ │ │ - "65902066": 17, │ │ │ │ + "65901616": 17, │ │ │ │ "680437": 6, │ │ │ │ + "682": [7, 21], │ │ │ │ "6827": [2, 27], │ │ │ │ "6875": 6, │ │ │ │ "695": 13, │ │ │ │ - "69977002": 17, │ │ │ │ + "69977045": 17, │ │ │ │ "700": [5, 22], │ │ │ │ "70099": 7, │ │ │ │ "709": 18, │ │ │ │ "714": 13, │ │ │ │ "7182818": 3, │ │ │ │ "71878": 13, │ │ │ │ "7215": 8, │ │ │ │ "7335e": 12, │ │ │ │ - "734": [8, 21], │ │ │ │ "74510330": 12, │ │ │ │ "74999948": 6, │ │ │ │ "750": 13, │ │ │ │ "755": 10, │ │ │ │ "756": 5, │ │ │ │ "757": 5, │ │ │ │ - "76279886": 10, │ │ │ │ + "76279843": 10, │ │ │ │ "76284516": 10, │ │ │ │ "7669": 15, │ │ │ │ + "769": [5, 21], │ │ │ │ "770238": 7, │ │ │ │ - "772": [9, 21], │ │ │ │ - "77327309": 17, │ │ │ │ + "77326741": 17, │ │ │ │ "776876": 7, │ │ │ │ "780924": 6, │ │ │ │ "7825": 18, │ │ │ │ "785": 6, │ │ │ │ "78539816": 6, │ │ │ │ "7899514": 18, │ │ │ │ "79210670": 5, │ │ │ │ "7961792": 10, │ │ │ │ - "79855794": 11, │ │ │ │ + "79986564": 11, │ │ │ │ "7e49": 20, │ │ │ │ "800": [5, 8, 14, 15], │ │ │ │ - "80229162": 5, │ │ │ │ + "80229163": 5, │ │ │ │ "80252613": 10, │ │ │ │ - "80253568": 10, │ │ │ │ + "80253574": 10, │ │ │ │ "803875": 13, │ │ │ │ "81249979": 6, │ │ │ │ "8125": 6, │ │ │ │ - "83231442": 17, │ │ │ │ + "83231421": 17, │ │ │ │ "84538080": 5, │ │ │ │ "8653514": 6, │ │ │ │ "866": 13, │ │ │ │ "87027": 8, │ │ │ │ "871969": 10, │ │ │ │ "875": 6, │ │ │ │ "888888": 27, │ │ │ │ "8903937": 14, │ │ │ │ "8923637137222027": 6, │ │ │ │ "89425": 7, │ │ │ │ - "896": [6, 21], │ │ │ │ "8974": 15, │ │ │ │ "9000": 7, │ │ │ │ "90331537": 12, │ │ │ │ "9137": 7, │ │ │ │ "91629786": 6, │ │ │ │ "9180": 7, │ │ │ │ "9181": 7, │ │ │ │ @@ -741,19 +745,19 @@ │ │ │ │ "9545": [2, 27], │ │ │ │ "96283": 8, │ │ │ │ "963": 6, │ │ │ │ "96333090": 10, │ │ │ │ "96333133": 10, │ │ │ │ "97313428": 17, │ │ │ │ "976": 6, │ │ │ │ - "9760818": 17, │ │ │ │ - "98224426": 17, │ │ │ │ + "9760277": 17, │ │ │ │ + "98224478": 17, │ │ │ │ "984": 5, │ │ │ │ "98406394": 5, │ │ │ │ - "984064046939685": 5, │ │ │ │ + "984064048969551": 5, │ │ │ │ "98406405": 5, │ │ │ │ "98700821": 10, │ │ │ │ "98700854": 10, │ │ │ │ "99003": 7, │ │ │ │ "991": 6, │ │ │ │ "99349787": 5, │ │ │ │ "994": 6,
-
│ │ │
If yerr is supplied or if the model included weights, errorbars │ │ │ will also be plotted.
│ │ │-
│ │ │
-
│ │ │
-
│ │ │
Hessian of objective function
-
│ │ │
It assumes that the input Parameters have been initialized, and a │ │ │ function to minimize has been properly set up.
│ │ │-
│ │ │