Skip to content

best_fit

Python reference for nagasim.inputfit.best_fit.

Fit candidate distributions to a sample and return the winner.

The winner is the best by AIC, ties broken by the KS statistic. This is the one place the criterion is applied, so the fit data binding and the MES parameter feed cannot drift apart.

Parameters:

Name Type Description Default
values sequence of float

The observed sample.

required
candidates list of str

Distribution families to try (default: all that can be fit).

None
shift bool

Allow a location shift.

False

Returns:

Type Description
Fit or None

The winning fit (distribution, dist_params, aic, ks_stat and more), or None when no family could be fit at all.

See Also

nagasim.calibrate.calibrate : Tune a model rather than fit an input.

Examples:

>>> from nagasim.inputfit import best_fit
>>> fit = best_fit([1.0, 1.4, 0.7, 2.2, 1.1, 0.9, 1.6, 3.0, 0.8, 1.2])
>>> isinstance(fit.distribution, str) and fit.aic == fit.aic
True