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
median(data)
median_low(data)
median_high(data)
median_grouped(data, interval = 1.0)
mode(data)
multimode(data)
quantiles(data, n: int = 4, method: str = "exclusive")
mean(data)
fmean(data, weights = None)
geometric_mean(data)
harmonic_mean(data, weights = None)
pvariance(data, mu = None)
pstdev(data, mu = None)
variance(data, xbar = None)
stdev(data, xbar = None)
covariance(xdata, ydata)
correlation(xdata, ydata, method: str = "linear")
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