pub struct OnlineStats { /* private fields */ }Expand description
Online statistics accumulator using Welford’s algorithm.
Tracks mean, variance, and lag-1 autocorrelation incrementally with O(1) overhead per sample. This is used to detect condition drift between calibration and the adaptive loop.
§Example
use tacet_core::statistics::OnlineStats;
let mut stats = OnlineStats::new();
for x in [1.0, 2.0, 3.0, 4.0, 5.0] {
stats.update(x);
}
let snapshot = stats.finalize();
assert!((snapshot.mean - 3.0).abs() < 1e-10);Implementations§
Source§impl OnlineStats
impl OnlineStats
Sourcepub fn update(&mut self, x: f64)
pub fn update(&mut self, x: f64)
Update statistics with a new sample.
Uses Welford’s online algorithm for numerically stable variance computation. Also tracks lag-1 autocorrelation incrementally.
§Arguments
x- The new sample value
Sourcepub fn finalize(&self) -> StatsSnapshot
pub fn finalize(&self) -> StatsSnapshot
Finalize and return the computed statistics.
§Returns
A StatsSnapshot containing mean, variance, and lag-1 autocorrelation.
Returns default values (0.0) if insufficient samples.
Trait Implementations§
Source§impl Clone for OnlineStats
impl Clone for OnlineStats
Source§fn clone(&self) -> OnlineStats
fn clone(&self) -> OnlineStats
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 OnlineStats
impl Debug for OnlineStats
Auto Trait Implementations§
impl Freeze for OnlineStats
impl RefUnwindSafe for OnlineStats
impl Send for OnlineStats
impl Sync for OnlineStats
impl Unpin for OnlineStats
impl UnwindSafe for OnlineStats
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.