Module stats

Module stats 

Source
Expand description

Statistical basic functions (Sprint 6)

Implementations target Excel semantic parity for: LARGE, SMALL, RANK.EQ, RANK.AVG, MEDIAN, STDEV.S, STDEV.P, VAR.S, VAR.P, PERCENTILE.INC, PERCENTILE.EXC, QUARTILE.INC, QUARTILE.EXC.

Notes:

  • We currently materialize numeric values into a Vec. For large ranges this could be optimized with streaming selection algorithms (nth_element / partial sort). TODO(perf).
  • Text/boolean coercion nuance: For Excel statistical functions, values coming from range references should ignore text and logical values (they are skipped), while direct scalar arguments still coerce (e.g. =STDEV(1,TRUE) treats TRUE as 1). This file now implements that distinction. TODO(excel-nuance): refine numeric text literal vs non‑numeric text handling.
  • Errors encountered in any argument propagate immediately.
  • Empty numeric sets produce Excel-specific errors (#NUM! for LARGE/SMALL, #N/A for rank target out of range, #DIV/0! for STDEV/VAR sample with n < 2, etc.).

Structs§

LARGE
MEDIAN
ModeMultiFn
ModeSingleFn
PercentileExc
PercentileInc
QuartileExc
QuartileInc
RankAvgFn
RANK.AVG(number, ref, [order]) ties return average of ranks
RankEqFn
RANK.EQ(number, ref, [order]) Excel semantics:
SMALL
StdevPop
StdevSample
VarPop
VarSample

Functions§

register_builtins