Struct Running Stats
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.
Fields
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/max in empty digests.
Implementations
impl RunningStats
impl RunningStats
new
pub fn new() -> Self
Creates a new empty RunningStats.
has_samples
pub fn has_samples(&self) -> bool
Returns true if any samples have been added.
add_sample
pub 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).
merge
pub 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_metrics
pub 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.
Trait Implementations
impl Clone for RunningStats
impl Clone for RunningStats
clone
fn clone(&self) -> RunningStats
clone_from
fn clone_from(&mut self, source: &Self)
impl Debug for RunningStats
impl Debug for RunningStats
fmt
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for RunningStats
impl Default for RunningStats
default
fn default() -> Self
impl<'de> Deserialize<'de> for RunningStats
impl<'de> Deserialize<'de> for RunningStats
deserialize
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Serialize for RunningStats
impl Serialize for RunningStats
serialize
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where
__S: Serializer,