pub struct Statistics<T> { /* private fields */ }Expand description
A structure that computes various statistics over a fixed-size window of values.
Statistics<T> maintains a circular buffer of values and computes statistical measures
such as mean, variance, standard deviation, median, etc. It can handle both single value
statistics and paired statistics (when T is a tuple).
The structure automatically updates statistics as new values are added and old values are removed from the window, making it efficient for streaming data analysis.
§Type Parameters
T- The type of values to compute statistics over. Can be a single numeric type or a tuple for paired statistics.
Implementations§
Source§impl<T> Statistics<T>
impl<T> Statistics<T>
Sourcepub const fn len(&self) -> usize
pub const fn len(&self) -> usize
Returns the current number of elements in the buffer.
§Returns
usize- The current number of elements in the buffer
Trait Implementations§
Source§impl<T: Clone> Clone for Statistics<T>
impl<T: Clone> Clone for Statistics<T>
Source§fn clone(&self) -> Statistics<T>
fn clone(&self) -> Statistics<T>
Returns a copy 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<T: Debug> Debug for Statistics<T>
impl<T: Debug> Debug for Statistics<T>
Source§impl<T: Float + Default> PairedStatistics<T> for Statistics<(T, T)>
impl<T: Float + Default> PairedStatistics<T> for Statistics<(T, T)>
Source§fn next(&mut self, (x, y): (T, T)) -> &mut Self
fn next(&mut self, (x, y): (T, T)) -> &mut Self
Updates the paired statistical calculations with a new value pair in the time series Read more
Source§fn cov(&self) -> Option<T>
fn cov(&self) -> Option<T>
Returns the covariance of the paired values in the rolling window Read more
Source§impl<T: Float + Default + Sum> SingleStatistics<T> for Statistics<T>
impl<T: Float + Default + Sum> SingleStatistics<T> for Statistics<T>
Source§fn next(&mut self, value: T) -> &mut Self
fn next(&mut self, value: T) -> &mut Self
Updates the statistical calculations with a new value in the time series Read more
Source§fn sum_sq(&self) -> Option<T>
fn sum_sq(&self) -> Option<T>
Returns the sum of squares of all values in the rolling window Read more
Source§fn mean(&self) -> Option<T>
fn mean(&self) -> Option<T>
Returns the arithmetic mean of all values in the rolling window Read more
Source§fn mean_sq(&self) -> Option<T>
fn mean_sq(&self) -> Option<T>
Returns the mean of squares of all values in the rolling window Read more
Source§fn mode(&mut self) -> Option<T>
fn mode(&mut self) -> Option<T>
Returns the mode (most frequently occurring value) in the rolling window Read more
Source§fn median(&mut self) -> Option<T>
fn median(&mut self) -> Option<T>
Returns the median (middle value) of the rolling window Read more
Source§fn mean_absolute_deviation(&self) -> Option<T>
fn mean_absolute_deviation(&self) -> Option<T>
Returns the mean absolute deviation of values in the rolling window Read more
Source§fn median_absolute_deviation(&mut self) -> Option<T>
fn median_absolute_deviation(&mut self) -> Option<T>
Returns the median absolute deviation of values in the rolling window Read more
Source§fn variance(&self) -> Option<T>
fn variance(&self) -> Option<T>
Returns the variance of values in the rolling window Read more
Source§fn stddev(&self) -> Option<T>
fn stddev(&self) -> Option<T>
Returns the standard deviation of values in the rolling window Read more
Source§fn zscore(&self) -> Option<T>
fn zscore(&self) -> Option<T>
Returns the z-score of the most recent value relative to the rolling window Read more
Source§fn linreg_slope(&self) -> Option<T>
fn linreg_slope(&self) -> Option<T>
Returns the slope of the linear regression line Read more
Source§fn linreg_slope_intercept(&self) -> Option<(T, T)>
fn linreg_slope_intercept(&self) -> Option<(T, T)>
Returns both slope and intercept of the linear regression line Read more
Source§fn linreg_intercept(&self) -> Option<T>
fn linreg_intercept(&self) -> Option<T>
Returns the y-intercept of the linear regression line Read more
Source§fn linreg_angle(&self) -> Option<T>
fn linreg_angle(&self) -> Option<T>
Returns the angle (in degrees) of the linear regression line Read more
Source§fn linreg(&self) -> Option<T>
fn linreg(&self) -> Option<T>
Returns the linear regression value (predicted y) for the last position Read more
Source§fn max_drawdown(&mut self) -> Option<T>
fn max_drawdown(&mut self) -> Option<T>
Returns the maximum drawdown in the window Read more
Source§fn diff(&self) -> Option<T>
fn diff(&self) -> Option<T>
Returns the difference between the last and first values Read more
Source§fn pct_change(&self) -> Option<T>
fn pct_change(&self) -> Option<T>
Returns the percentage change between the first and last values Read more
Source§fn log_return(&self) -> Option<T>
fn log_return(&self) -> Option<T>
Returns the logarithmic return between the first and last values Read more
Auto Trait Implementations§
impl<T> Freeze for Statistics<T>where
T: Freeze,
impl<T> RefUnwindSafe for Statistics<T>where
T: RefUnwindSafe,
impl<T> Send for Statistics<T>where
T: Send,
impl<T> Sync for Statistics<T>where
T: Sync,
impl<T> Unpin for Statistics<T>where
T: Unpin,
impl<T> UnwindSafe for Statistics<T>where
T: UnwindSafe,
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