Trait basic_dsp_vector::StatisticsOps
[−]
[src]
pub trait StatisticsOps<T>: Sized where T: Sized { fn statistics(&self) -> T; fn statistics_splitted(&self, len: usize) -> Vec<T>; }
Required Methods
fn statistics(&self) -> T
Calculates the statistics of the data contained in the vector.
Example
use basic_dsp_vector::*; let vector = vec!(1.0, 2.0, 3.0, 4.0, 5.0, 6.0).to_complex_time_vec(); let result = vector.statistics(); assert_eq!(result.sum, Complex32::new(9.0, 12.0)); assert_eq!(result.count, 3); assert_eq!(result.average, Complex32::new(3.0, 4.0)); assert!((result.rms - Complex32::new(3.4027193, 4.3102784)).norm() < 1e-4); assert_eq!(result.min, Complex32::new(1.0, 2.0)); assert_eq!(result.min_index, 0); assert_eq!(result.max, Complex32::new(5.0, 6.0)); assert_eq!(result.max_index, 2); }Run
fn statistics_splitted(&self, len: usize) -> Vec<T>
Calculates the statistics of the data contained in the vector as if the vector would
have been split into len pieces. 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!(1.0, 2.0, 3.0, 4.0, 5.0, 6.0).to_complex_time_vec(); let result = vector.statistics_splitted(2); assert_eq!(result[0].sum, Complex32::new(6.0, 8.0)); assert_eq!(result[1].sum, Complex32::new(3.0, 4.0)); }Run
Implementors
impl<S, T, N, D> StatisticsOps<Statistics<T>> for DspVec<S, T, N, D> where S: ToSlice<T>, T: RealNumber, N: RealNumberSpace, D: Domainimpl<S, T, N, D> StatisticsOps<Statistics<Complex<T>>> for DspVec<S, T, N, D> where S: ToSlice<T>, T: RealNumber, N: ComplexNumberSpace, D: Domain