Expand description
Descriptive statistics with numerical stability guarantees.
All functions in this module handle edge cases explicitly and use numerically stable algorithms to avoid catastrophic cancellation.
§Algorithms
- Mean: Kahan compensated summation for O(ε) error independent of n.
- Variance/StdDev: Welford’s online algorithm. Reference: Welford (1962), “Note on a Method for Calculating Corrected Sums of Squares and Products”, Technometrics 4(3).
- Quantile: R-7 linear interpolation (default in R, Python, Excel). Reference: Hyndman & Fan (1996), “Sample Quantiles in Statistical Packages”, The American Statistician 50(4).
Structs§
- Welford
Accumulator - Streaming accumulator for mean, variance, skewness, and kurtosis.
Functions§
- covariance
- Computes the sample covariance between two datasets.
- kahan_
sum - Neumaier compensated summation for O(ε) error independent of
n. - kurtosis
- Computes Fisher’s excess kurtosis (G₂) with bias correction.
- max
- Returns the maximum value in the slice.
- mean
- Computes the arithmetic mean using Kahan compensated summation.
- median
- Computes the median of
datawithout mutating the input. - min
- Returns the minimum value in the slice.
- population_
std_ dev - Computes the population standard deviation.
- population_
variance - Computes the population variance using Welford’s online algorithm.
- quantile
- Computes the
p-th quantile using the R-7 linear interpolation method. - quantile_
sorted - Computes the
p-th quantile on pre-sorted data (R-7 method). - skewness
- Computes Fisher’s adjusted sample skewness (G₁) with bias correction.
- std_dev
- Computes the sample standard deviation.
- variance
- Computes the sample variance using Welford’s online algorithm.