conf_interval(minimizer,
p_names=None,
sigmas=( 0.674, 0.95, 0.997) ,
trace=False,
maxiter=200,
verbose=False,
prob_func=None)
| source code
|
Calculates the confidence interval for parameters
from the given minimizer.
The parameter for which the ci is calculated will be varied, while
the remaining parameters are re-optimized for minimizing chi-square.
The resulting chi-square is used to calculate the probability with
a given statistic e.g. F-statistic. This function uses a 1d-rootfinder
from scipy to find the values resulting in the searched confidence
region.
Parameters
----------
minimizer : Minimizer
The minimizer to use, should be already fitted via leastsq.
p_names : list, optional
Names of the parameters for which the ci is calculated. If None,
the ci is calculated for every parameter.
sigmas : list, optional
The probabilities (1-alpha) to find. Default is 1,2 and 3-sigma.
trace : bool, optional
Defaults to False, if true, each result of a probability calculation
is saved along with the parameter. This can be used to plot so
called "profile traces".
Returns
-------
output : dict
A dict, which contains a list of (sigma, vals)-tuples for each name.
trace_dict : dict
Only if trace is set true. Is a dict, the key is the parameter which
was fixed.The values are again a dict with the names as keys, but with
an additional key 'prob'. Each contains an array of the corresponding
values.
See also
--------
conf_interval2d
Other Parameters
----------------
maxiter : int
Maximum of iteration to find an upper limit.
prob_func : ``None`` or callable
Function to calculate the probability from the optimized chi-square.
Default (``None``) uses built-in f_compare (F test).
verbose: bool
print extra debuggin information. Default is ``False``.
Examples
--------
>>> from lmfit.printfuncs import *
>>> mini=minimize(some_func, params)
>>> mini.leastsq()
True
>>> report_errors(params)
... #report
>>> ci=conf_interval(mini)
>>> report_ci(ci)
... #report
Now with quantiles for the sigmas and using the trace.
>>> ci, trace=conf_interval(mini, sigmas=(0.25,0.5,0.75,0.999),trace=True)
>>> fixed=trace['para1']['para1']
>>> free=trace['para1']['not_para1']
>>> prob=trace['para1']['prob']
This makes it possible to plot the dependence between free and fixed.
|