Trait peroxide::statistics::stat::Statistics

source ·
pub trait Statistics {
    type Array;
    type Value;

    // Required methods
    fn mean(&self) -> Self::Value;
    fn var(&self) -> Self::Value;
    fn sd(&self) -> Self::Value;
    fn cov(&self) -> Self::Array;
    fn cor(&self) -> Self::Array;
}
Expand description

Statistics Trait

It contains mean, var, sd, cov

Required Associated Types§

Required Methods§

source

fn mean(&self) -> Self::Value

source

fn var(&self) -> Self::Value

source

fn sd(&self) -> Self::Value

source

fn cov(&self) -> Self::Array

source

fn cor(&self) -> Self::Array

Implementations on Foreign Types§

source§

impl Statistics for Vec<f32>

source§

fn mean(&self) -> f32

Mean

Uses welfords online algorithm for numerically stable computation.

§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3,4,5);
    assert_eq!(a.mean(), 3.0);
}
source§

fn var(&self) -> f32

Variance

Uses welfords online algorithm for numerically stable computation.

§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3,4,5);
    assert_eq!(a.var(), 2.5);
}
source§

fn sd(&self) -> f32

Standard Deviation

§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3);
    assert!(nearly_eq(a.sd(), 1f64)); // Floating Number Error
}
source§

type Array = Vec<f32>

source§

type Value = f32

source§

fn cov(&self) -> Vec<f32>

source§

fn cor(&self) -> Vec<f32>

source§

impl Statistics for Vec<f64>

source§

fn mean(&self) -> f64

Mean

Uses welfords online algorithm for numerically stable computation.

§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3,4,5);
    assert_eq!(a.mean(), 3.0);
}
source§

fn var(&self) -> f64

Variance

Uses welfords online algorithm for numerically stable computation.

§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3,4,5);
    assert_eq!(a.var(), 2.5);
}
source§

fn sd(&self) -> f64

Standard Deviation

§Examples
#[macro_use]
extern crate peroxide;
use peroxide::fuga::*;

fn main() {
    let a = c!(1,2,3);
    assert!(nearly_eq(a.sd(), 1f64)); // Floating Number Error
}
source§

type Array = Vec<f64>

source§

type Value = f64

source§

fn cov(&self) -> Vec<f64>

source§

fn cor(&self) -> Vec<f64>

Implementors§