Generated from cargo doc --no-deps -p nemo-relay -p nemo-relay-adaptive -p nemo-relay-ffi.
pub struct RunningStats {
pub count: u64,
pub mean: f64,
pub m2: f64,
pub digest: TDigest,
}
Streaming statistics tracker combining Welford’s online algorithm for mean/variance with a TDigest for streaming percentile estimation.
This replaces NAT’s batch MetricsAccumulator which stores all raw samples. RunningStats provides O(1) memory usage with merge() support for incremental trie updates.
count: u64Number of samples added.
mean: f64Running mean (Welford).
m2: f64Sum of squared differences from the mean (Welford M2).
digest: TDigestTDigest for streaming percentile estimation.
Uses custom serde to handle NaN min/max in empty digests.
impl RunningStatsimpl RunningStats
newpub fn new() -> Self
Creates a new empty RunningStats.
has_samplespub fn has_samples(&self) -> bool
Returns true if any samples have been added.
add_samplepub 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_unsorted which returns a new digest (it consumes self by value).
mergepub fn merge(&mut self, other: &RunningStats)
Merges another RunningStats into this one using parallel Welford merge and TDigest merge_digests.
If other is empty, this is a no-op.
compute_metricspub fn compute_metrics(&self) -> PredictionMetrics
Computes PredictionMetrics from the current accumulator state.
Returns PredictionMetrics::default() if no samples have been added. Percentiles (p50, p90, p95) are estimated from the TDigest.
impl Clone for RunningStatsimpl Clone for RunningStats
clonefn clone(&self) -> RunningStats
clone_fromfn clone_from(&mut self, source: &Self)
impl Debug for RunningStatsimpl Debug for RunningStats
fmtfn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for RunningStatsimpl Default for RunningStats
defaultfn default() -> Self
impl<'de> Deserialize<'de> for RunningStatsimpl<'de> Deserialize<'de> for RunningStats
deserializefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Serialize for RunningStatsimpl Serialize for RunningStats
serializefn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where
__S: Serializer,