pub fn variance_par_iter_val<It, T>(data: It) -> Twhere
    T: Clone + Div<f64, Output = T> + Sum<T> + Sum<It::Item> + Send + Sub<T, Output = T> + Mul<T, Output = T> + Zero,
    It: IndexedParallelIterator<Item = T> + Clone,
Expand description

Compute the variance (squared of standard deviation) from a [rayon::iter::IndexedParallelIterator] by value.

The alternative for the variance from a iterator that yields reference is variance_par_iter.

Example

use lattice_qcd_rs::statistics::variance_par_iter_val;
use rayon::prelude::*;

fn expensive_computation(input: &f64) -> f64 {
    input * 2_f64
}

let vec = vec![1_f64, 2_f64, 3_f64, 4_f64];
let mean = variance_par_iter_val(vec.par_iter().map(|input| expensive_computation(input)));