mod accumulator#
- module accumulator#
Streaming statistics accumulator using Welford’s algorithm and TDigest.
Structs and Unions
- struct AccumulatorState#
Maps trie path strings to their node accumulators.
Keys are
/-joined path strings (e.g.,"workflow/agent") becauseVec<String>is notHash. This matches the research recommendation.- nodes: HashMap<String, NodeAccumulators>#
Node accumulators keyed by
/-joined path string.
- struct NodeAccumulators#
Per-node accumulators for all metric types, keyed by call index.
Mirrors NAT’s
_NodeAccumulatorsstructure but uses streamingRunningStatsinstead of batchMetricsAccumulator.- remaining_calls: HashMap<u32, RunningStats>#
Remaining-calls stats per call index.
- interarrival_ms: HashMap<u32, RunningStats>#
Interarrival-time stats per call index.
- output_tokens: HashMap<u32, RunningStats>#
Output-tokens stats per call index.
- sensitivity: HashMap<u32, RunningStats>#
Sensitivity stats per call index.
- all_remaining_calls: RunningStats#
Aggregated remaining-calls stats across all call indices.
- all_interarrival_ms: RunningStats#
Aggregated interarrival-time stats across all call indices.
- all_output_tokens: RunningStats#
Aggregated output-tokens stats across all call indices.
- all_sensitivity: RunningStats#
Aggregated sensitivity stats across all call indices.
- struct RunningStats#
Streaming statistics tracker combining Welford’s online algorithm for mean/variance with a TDigest for streaming percentile estimation.
This replaces NAT’s batch
MetricsAccumulatorwhich stores all raw samples.RunningStatsprovides O(1) memory usage withmerge()support for incremental trie updates.- count: u64#
Number of samples added.
- mean: f64#
Running mean (Welford).
- m2: f64#
Sum of squared differences from the mean (Welford M2).
- digest: TDigest#
TDigest for streaming percentile estimation.
Uses custom serde to handle NaN
min/maxin empty digests.
Implementations
- impl RunningStats#
Functions
- fn add_sample(&mut self, value: f64)#
Adds a single sample, updating both Welford accumulators and TDigest.
Welford’s online algorithm maintains running mean and M2 (sum of squared differences from the mean). TDigest is updated via
merge_unsortedwhich returns a new digest (it consumesselfby value).
- fn compute_metrics(&self) -> PredictionMetrics#
Computes
PredictionMetricsfrom the current accumulator state.Returns
PredictionMetrics::default()if no samples have been added. Percentiles (p50, p90, p95) are estimated from the TDigest.
- fn has_samples(&self) -> bool#
Returns
trueif any samples have been added.
- fn merge(&mut self, other: &RunningStats)#
Merges another
RunningStatsinto this one using parallel Welford merge and TDigestmerge_digests.If
otheris empty, this is a no-op.
- fn new() -> Self#
Creates a new empty
RunningStats.
Traits implemented
- impl Default for RunningStats#