Trait basic_dsp_vector::PreciseStatisticsOps [] [src]

pub trait PreciseStatisticsOps<T>: Sized where T: Sized {
    fn statistics_prec(&self) -> T;
    fn statistics_splitted_prec(&self, len: usize) -> Vec<T>;
}

Offers the same functionality as the StatisticsOps trait but the statistics are calculated in a more precise (and slower) way.

Required Methods

Calculates the statistics of the data contained in the vector using a more precise but slower algorithm.

Example

use basic_dsp_vector::*;
let vector: Vec<f32> = vec!(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
let vector = vector.to_complex_time_vec();
let result = vector.statistics_prec();
assert_eq!(result.sum, Complex64::new(9.0, 12.0));
assert_eq!(result.count, 3);
assert_eq!(result.average, Complex64::new(3.0, 4.0));
assert!((result.rms - Complex64::new(3.4027193, 4.3102784)).norm() < 1e-4);
assert_eq!(result.min, Complex64::new(1.0, 2.0));
assert_eq!(result.min_index, 0);
assert_eq!(result.max, Complex64::new(5.0, 6.0));
assert_eq!(result.max_index, 2);
}

Calculates the statistics of the data contained in the vector as if the vector would have been split into len pieces using a more precise but slower algorithm. self.len should be dividable by len without a remainder, but this isn't enforced by the implementation.

Example

use basic_dsp_vector::*;
let vector: Vec<f32> = vec!(1.0, 2.0, 3.0, 4.0, 5.0, 6.0);
let vector = vector.to_complex_time_vec();
let result = vector.statistics_splitted_prec(2);
assert_eq!(result[0].sum, Complex64::new(6.0, 8.0));
assert_eq!(result[1].sum, Complex64::new(3.0, 4.0));
}

Implementors