models.simulate_from_means()

Joint predictive draws from fitted means, for engines that give only

Usage

models.simulate_from_means(
    family,
    means,
    n_sims,
    seed,
    dispersion=None,
    weights=None,
    theta=None,
    power=None
)

a mean per row (the boosting adapters): the family adds process noise and several mean vectors (bootstrap refits) add parameter uncertainty.

Simulation i uses stream i of seed: it picks one mean vector uniformly, then draws each row’s response from the family with that mean, the row’s dispersion and the row’s weight. Components are keyed row = 0, 1, ..., as GlmFit.predict_distribution keys them.

Parameters

family: str

As in Glm.

means: list of list of float

One or more mean vectors, one value per row each.

n_sims: int
seed: int
dispersion: float or list of float = None

One value for every row, or one per row (from a dispersion model); 1 by default.

weights: list of float = None

Prior weights; 1 by default.

theta: float = None

Negative binomial theta, Tweedie power.

power: float = None
Negative binomial theta, Tweedie power.

Returns

PredictiveDistribution

Examples

>>> from prospicio.models import simulate_from_means
>>> pd = simulate_from_means("poisson", [[0.1, 0.4]], 20_000, 7)
>>> round(pd.mean(), 1)

0.5