mean

Function mean 

Source
pub fn mean<F>(
    x: &ArrayBase<ViewRepr<&F>, Dim<[usize; 1]>>,
) -> Result<F, StatsError>
where F: Float<Output = F> + Sum + Div + Display + SimdUnifiedOps,
Expand description

Compute the arithmetic mean of a data set.

§Arguments

  • x - Input data

§Returns

  • The mean of the data

§Examples

use scirs2_core::ndarray::array;
use scirs2_stats::mean;

let data = array![1.0f64, 2.0, 3.0, 4.0, 5.0];
let result = mean(&data.view()).expect("Operation failed");
assert!((result - 3.0).abs() < 1e-10);