satlas.stats.fitting.likelihood_fit¶
-
satlas.stats.fitting.
likelihood_fit
(f, x, y, xerr=None, func=<function poisson_llh at 0x0000000008DF2D08>, method='nelder-mead', method_kws={}, walking=False, walk_kws={}, verbose=True, hessian=True)[source]¶ Fits the given model to the given data using the Maximum Likelihood Estimation technique. The given function is used to calculate the loglikelihood. After the fit, the message from the optimizer is printed and returned.
Parameters: - f (
BaseModel
) – Model to be fitted to the data. - x (array_like) – Experimental data for the x-axis.
- y (array_like) – Experimental data for the y-axis.
Other Parameters: - xerr (array_like, optional) – Estimated value for the uncertainty on the x-values. Set to None to ignore this uncertainty. Defaults to None.
- func (function, optional) – Used to calculate the loglikelihood that the data is drawn from a distribution given a model value. Should accept input as (y_data, y_model). Defaults to the Poisson loglikelihood.
- method (str, optional) – Selects the algorithm to be used by the minimizer used by LMFIT. See LMFIT documentation for possible values. Defaults to ‘nelder-mead’.
- method_kws (dict, optional) – Dictionary containing the keywords to be passed to the minimizer.
- walking (boolean, optional) – If True, the uncertainty on the parameters is estimated by performing a random walk in parameter space and evaluating the loglikelihood. Defaults to False.
- walk_kws (dictionary) – Contains the keywords for the
likelihood_walk
function, used if walking is set to True. - verbose (boolean, optional) – When set to True, a tqdm-progressbar in the terminal is maintained. Defaults to True.
- hessian (boolean, optional) – When set to True, the Hessian estimate of the uncertainty will be calculated.
Returns: success, message – Boolean indicating the success of the optimization and the message from the optimizer.
Return type: tuple
- f (