pyfli.cm_stats.deviance#
Poisson deviance statistics: per-gate terms, the summed and reduced deviance, and its expectation (and variance) under the model for photon counts.
Functions
|
Expected deviance minus fitted parameters, |
|
Expected Poisson deviance |
|
Poisson deviance: |
|
|
|
Exact |
|
Per-gate Poisson deviance |
|
|
- poisson_deviance_terms(model, data, floor=1e-12, nonpositive='zero', data_floor=1e-9)[source]#
Per-gate Poisson deviance
2 (mu - d + d ln(d / mu))withmufloored at floor.nonpositive sets the
d ln(d / mu)term of gates withd <= 0:"zero"(0),"nan"(scipyxlogy: 0 ford = 0, NaN ford < 0) or"floor"(d ln(max(d, data_floor) / mu)on every gate).
- poisson_deviance(model, data, axis=-1, **kwargs)[source]#
Poisson deviance:
poisson_deviance_terms()summed along axis (gates withd <= 0contribute2 * (mu - d)by default). For counts drawn from the model,deviance / (sum E[D_k] - p)averages 1 (seereduced_poisson_deviance()).
- poisson_deviance_moment_table(mu_min=MU_MIN, mu_max=MU_SWITCH, n_grid=N_GRID)[source]#
(ln mu, E[d], Var[d])of the per-gate deviance on a log grid ofmu, exact by summation.
- poisson_deviance_moments(model)[source]#
Exact
(E[d], Var[d])of the per-gate deviance ford ~ Poisson(mu), element-wise: tabulated belowmu = 1e3(0 atmu = 0), thenE = 1 + 1/(6 mu) + 1/(6 mu^2)andVar = 2 + 2/(3 mu) + 4/(3 mu^2).
- expected_poisson_deviance(model)[source]#
Expected Poisson deviance
E[2 * (mu - d + d * ln(d / mu))]of a gate with expected count mu (element-wise), ford ~ Poisson(mu): about2 mu ln(1/mu)formu -> 0, peaks near 1.15 atmu ~ 1and tends to1 + 1/(6 mu)for largemu(poisson_deviance_moments()).
- deviance_dof(model, n_params, weights=None, axis=-1)[source]#
Expected deviance minus fitted parameters,
sum_k w_k E[d_k] - n_params: the reduced-deviance denominator.