stats/cdf_utils library

Empirical CDF and cumulative histogram for numeric samples — roadmap #574.

Complements the bin-counting histogramFixed/histogramQuantile in collections/histogram_utils.dart with the cumulative view: what fraction of samples fall at or below a value. The cumulative histogram reuses histogramFixed directly so the two stay consistent.

Classes

CdfPoint
One step of an empirical CDF: a sample value and the cumulative probability p = (count of samples ≤ value) / n, in [0, 1].

Functions

cdfAt(List<num> values, num x) double
The empirical CDF of values evaluated at x: the fraction of samples that are ≤ x, in [0, 1]. Returns 0 for no samples. Audited: 2026-06-12 11:26 EDT
cumulativeHistogram(List<num> values, List<num> edges) List<int>
Cumulative histogram: the running total of histogramFixed(values, edges), so bin i holds the count of samples in bins 0..i — the CDF in bin form. Returns an empty list when edges has fewer than two entries.
empiricalCdf(List<num> values) List<CdfPoint>
Builds the empirical CDF of values: one CdfPoint per DISTINCT value in ascending order, with p the running fraction of samples ≤ that value. Returns an empty list for no samples. Does not mutate values.