# suggest_warmup

Python reference for `nagasim.experiments.suggest_warmup`.

`nagasim.experiments.suggest_warmup`

```python
suggest_warmup(source, batch: int = 5)
```

Suggest a warm-up length from a run's entity log with MSER-5.

MSER-5 (White 1997) groups the output series into batches of *batch*
observations and picks the truncation point ``d`` that minimises
``sum_{i>d} (m_i - mean_{i>d})**2 / (k - d)**2`` over the batch means
``m_1..m_k``: the head to drop that leaves the most precise estimate of the
steady-state mean. The series is the entity throughput time ordered by exit
time and averaged across replications.

Parameters
----------
source : dict or DataFrame
    A results dict from `nagasim.api.run_model`, or an entity-log frame with
    the columns ``Run``, ``Exited At`` and ``Throughput Time``.
batch : int, default 5
    Observations per batch.

Returns
-------
WarmupSuggestion
    ``warmup`` is the exit time of the first observation that survives the
    truncation, in model time units, ready for a run's warm-up setting.
    ``reliable`` is False when the minimum falls in the second half of the
    batch means. With few batches left the denominator dominates, so a series
    still drifting always looks best when truncated near the end; read such a
    suggestion as "the run is too short to tell".

See Also
--------
nagasim.api.run_model : Produces the results this reads.

Examples
--------
>>> from pathlib import Path
>>> import nagasim
>>> from nagasim import api, experiments
>>> path = Path(nagasim.__file__).parent / "models" / "single_server.json"
>>> results = api.run_model(str(path), replications=2, run_length=300, warmup=0, seed=0)
>>> suggestion = experiments.suggest_warmup(results)
>>> suggestion.warmup >= 0 and suggestion.reliable in (True, False)
True
