One Atom, Many Statistics: The Statistics API

Navigation:

Where the Spectrum library is a heterogeneous collection of bases, each effect a different \(\Phi\)/\(P\), the Statistics layer is the mirror image: a single numerical primitive reused for every statistical target. This is the “One Atom, Many Statistics” philosophy.

The Atom

Every fit reduces to one penalized weighted least-squares solve:

\[ \left(\Phi^\top W \Phi + n\,S\right)\theta = \Phi^\top W z. \]

A Gaussian mean fit calls it once; the default loss="l2" (with \(W=I\)) is bit-identical to the ordinary least-squares solver. Every non-Gaussian target changes only the working response \(z\) and the per-observation weights \(W = \mathrm{diag}(w_i)\), the high-performance linear algebra never changes, only the schedule that feeds it.

The Three Schedules (and the Risk layer above)

  1. IRLS: GLMs (Poisson/Gamma/Binomial), robust M-estimators and expectiles: \(z=\eta+(y-\mu)g'(\mu)\), \(w=1/(g'(\mu)^2 V(\mu))\). See Reweighted estimation.

  2. Location-scale (distributional): a {param: formula} dict composes two sub-atoms (an L2 location on \(\log y\), a Gamma scale on the squared residuals). See Distributional.

  3. EM mixture: the M-step is the weighted atom with responsibilities as weights. See Mixtures & copulas.

The post-fit risk bounds, conformal, ACI, EVT and epistemic uncertainty, operate on the predictions of any of these. See Risk: conformal / EVT.