# best_fit

Python reference for `nagasim.inputfit.best_fit`.

`nagasim.inputfit.best_fit`

```python
best_fit(values, candidates: list[str] | None = None, shift: bool = False)
```

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
----------
values : sequence of float
    The observed sample.
candidates : list of str, optional
    Distribution families to try (default: all that can be fit).
shift : bool, default False
    Allow a location shift.

Returns
-------
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
