Trait rustml::math::mean::Mean [] [src]

pub trait Mean<T> {
    fn mean(&self, dim: Dimension) -> T;
}

Trait to compute the mean of values.

Required Methods

fn mean(&self, dim: Dimension) -> T

Computes the mean over all elements for the specified dimension.

When computing the mean of a vector or a slice both are interpreted as a row vector. Thus, the only valid dimension for vectors or slices is Dimension::Row. For other dimensions or if the vector or slice is empty the function will always return zero.

Examples

use rustml::*;

let v = vec![1.0, 5.0, 9.0];
assert_eq!(v.mean(), 5.0);

Implementation details

Uses the Sum trait to compute the sum which is then divided by the number of values.

Implementors