statistics
Descriptive statistics and distributions for native numeric data.
The API follows CPython 3.14, including weighted means, ranked correlation,
regression, and kernel density estimation. Numeric aggregates return float;
median_low, median_high, and modes preserve the input element type.
Compensated floating-point arithmetic and widened integer intermediates avoid
common cancellation and overflow errors, but do not provide Decimal/Fraction
arithmetic. Random sampling accepts integer seeds. Remove NaNs before computing
order statistics; native floats do not retain Python object identity for NaNs.
Finite product overflow uses a fixed-point recovery accumulator. Supplied-center
dispersion is scaled, and integer relational statistics use shifted origins;
these can retain finite results and precision lost by CPython's float paths.
class StatisticsError(ValueError)
median(data) -> float
median_low(data)
median_high(data)
median_grouped(data, interval = 1.0) -> float
mode(data)
multimode(data)
quantiles(data, *, n: int = 4, method: str = "exclusive") -> List[float]
mean(data) -> float
fmean(data, weights = None) -> float
geometric_mean(data) -> float
harmonic_mean(data, weights = None) -> float
pvariance(data, mu = None) -> float
pstdev(data, mu = None) -> float
variance(data, xbar = None) -> float
stdev(data, xbar = None) -> float
covariance(xdata, ydata, /) -> float
correlation(xdata, ydata, /, *, method: str = "linear") -> float
linear_regression(xdata, ydata, /, *, proportional: bool = False)
kde(data, h, kernel: str = "normal", *, cumulative: bool = False)
Return a kernel density or cumulative distribution estimator.
kde_random(data, h, kernel: str = "normal", *, seed: Optional[int] = None)
Return a sampler with a private random generator and optional integer seed.
class NormalDist