math_ops::statistics

Trait Statistics

source
pub trait Statistics<T> {
    // Required methods
    fn mean(&self) -> Option<T>;
    fn var(&self) -> Option<T>;
    fn stddev(&self) -> Option<T>;
    fn median(&self) -> Option<T>;
    fn quantile(&self, q: T) -> Option<T>;
    fn iqr(&self) -> Option<T>;
    fn min(&self) -> Option<T>;
    fn max(&self) -> Option<T>;
    fn cumsum(&self) -> Vector<T>;
}
Expand description

Trait definition for Statistics, generic over type T. T is expected to be a floating-point type like f32 or f64.

Required Methods§

source

fn mean(&self) -> Option<T>

Computes the mean (average) of the data. Returns an Option where None represents an empty dataset.

source

fn var(&self) -> Option<T>

Computes the variance of the data. Returns an Option, where None represents an empty dataset. Variance is the average of the squared deviations from the mean.

source

fn stddev(&self) -> Option<T>

Computes the standard deviation of the data. Returns an Option, where None represents an empty dataset. Standard deviation is the square root of the variance.

source

fn median(&self) -> Option<T>

Computes the median of the data. Returns an Option, where None represents an empty dataset. The median is the value separating the higher half from the lower half.

source

fn quantile(&self, q: T) -> Option<T>

Computes the quantile for the given fraction q. q is expected to be a floating-point value between 0 and 1. Returns an Option where None represents an empty dataset. For example, q = 0.5 gives the median, q = 0.25 gives the 25th percentile.

source

fn iqr(&self) -> Option<T>

Computes the interquartile range (IQR) of the data. Returns an Option, where None represents an empty dataset. IQR is the range between the 25th percentile and 75th percentile.

source

fn min(&self) -> Option<T>

Returns the minimum value in the dataset, ignoring NaN values. Returns an Option, where None represents an empty dataset.

source

fn max(&self) -> Option<T>

Returns the maximum value in the dataset, ignoring NaN values. Returns an Option, where None represents an empty dataset.

source

fn cumsum(&self) -> Vector<T>

Computes the cumulative sum of the data. Returns a Vector<T>, where each element is the cumulative sum up to that index. NaN values are ignored in the summation.

Implementors§

source§

impl<T> Statistics<T> for Vector<T>