Skip to main content

aggregate.audit_grid()

Audits an FFT grid as aggregate 1.2.0’s sharpen does: builds

Usage

aggregate.audit_grid(
    frequency,
    severity,
    step=None,
    log2=None,
    *,
    eps=0.0001,
    power=2.0,
    good_enough=0.5,
    max_doublings=4,
    log2_cap=20,
    log2_floor=8
)

the compound distribution at the center and, unless it meets the target, at doubled and halved steps on the same and half the points, scores each cell by six moment errors against the exact moments, and chooses the best sound cell, preferring fewer points. Twice the points is tried only when nothing smaller meets the target.

A score of 1 is aggregate’s validation boundary: a relative error of eps in a mean, 10 eps in a cv, 100 eps in a skewness.

Parameters

frequency: a claim count
severity: a severity

Any distribution but Sampled.

step: float = None

The center’s step; by default recommend_grid’s at log2.

log2: int = None

The center’s 2**log2 points; by default 16, or recommend_grid’s when step is not given either.

eps: float = 1e-4
power: float = 2

The power mean of the terms.

good_enough: float = 0.5

The target score.

max_doublings: int = 4

Steps doubled or halved at most this many times each way.

log2_cap: int = 20

log2 never grows past it.

log2_floor: int = 8
The half-size row is tried only above it.

Returns

GridAudit

Raises

ValueError
If step is not positive and finite or log2 is not in 1..=30.

Examples

>>> from prospicio.aggregate import audit_grid
>>> from prospicio.distributions import Gamma, Poisson
>>> a = audit_grid(Poisson(50.0), Gamma.from_mean_cv(10.0, 0.5), step=0.5, log2=10)
>>> a.step, a.log2, a.grew

(1.0, 11, True)