Stats
Stats module: descriptive statistics on List(Float).
All functions are pure — no side effects. Primary input type: List(Float).
Functions that require non-empty input panic on empty list. sum and count always succeed (return 0.0 / 0 for empty).
Design: all sorting uses List.sort_by with Float comparison. Variance uses Welford's online algorithm for numerical stability.
Functions
Sum of all elements. Returns 0.0 for empty list.
Number of elements.
Arithmetic mean. Panics on empty list.
Minimum value. Panics on empty list.
Maximum value. Panics on empty list.
Percentile using linear interpolation. p must be in [0.0, 100.0]. Panics on empty list or out-of-range p.
Median (50th percentile). Panics on empty list.
Sample variance (denominator n-1). Returns 0.0 for a single element. Panics on empty list.
Population variance (denominator n). Returns 0.0 for a single element or empty list.
Sample standard deviation. Returns 0.0 for single element. Panics on empty.
Population standard deviation.
Mode: the most frequently occurring value. When there are ties, returns the first value encountered (in sorted order). Panics on empty list.
Sample covariance of two equal-length lists. Panics if lengths differ or if either list has fewer than 2 elements.
Pearson correlation coefficient. Returns value in [-1, 1]. Panics if lists have different lengths, fewer than 2 elements, or if either list has zero standard deviation.
Simple linear regression: y = slope * x + intercept. Returns (slope, intercept). Panics if lists have different lengths or fewer than 2 elements, or if xs has zero variance (vertical line).
Mean, returning Err on empty list instead of panicking.
Sample variance, returning Err on empty list.
Sample standard deviation, returning Err on empty or single-element list.
Minimum value, returning Err on empty list.
Maximum value, returning Err on empty list.