pub struct StreamingStats { /* private fields */ }Expand description
Streaming statistics calculator using Welford’s online algorithm. Computes mean, variance, and standard deviation in a single pass without storing all values in memory.
§Examples
use chie_shared::StreamingStats;
let mut stats = StreamingStats::new();
// Add some latency measurements (in ms)
for latency in [100.0, 105.0, 95.0, 110.0, 98.0] {
stats.add(latency);
}
assert_eq!(stats.count(), 5);
assert!((stats.mean() - 101.6).abs() < 0.1);
assert!(stats.std_dev() > 0.0);
// Merge statistics from another source
let mut other_stats = StreamingStats::new();
other_stats.add(102.0);
other_stats.add(108.0);
stats.merge(&other_stats);
assert_eq!(stats.count(), 7);Implementations§
Source§impl StreamingStats
impl StreamingStats
Sourcepub fn sample_variance(&self) -> f64
pub fn sample_variance(&self) -> f64
Get the sample variance (Bessel’s correction).
Sourcepub fn sample_std_dev(&self) -> f64
pub fn sample_std_dev(&self) -> f64
Get the sample standard deviation.
Sourcepub fn merge(&mut self, other: &StreamingStats)
pub fn merge(&mut self, other: &StreamingStats)
Merge another StreamingStats into this one.
Trait Implementations§
Source§impl Clone for StreamingStats
impl Clone for StreamingStats
Source§fn clone(&self) -> StreamingStats
fn clone(&self) -> StreamingStats
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StreamingStats
impl Debug for StreamingStats
Auto Trait Implementations§
impl Freeze for StreamingStats
impl RefUnwindSafe for StreamingStats
impl Send for StreamingStats
impl Sync for StreamingStats
impl Unpin for StreamingStats
impl UnwindSafe for StreamingStats
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more