Struct rv::dist::Empirical[][src]

pub struct Empirical { /* fields omitted */ }

An empirical distribution derived from samples.

WARNING: The ln_f and f methods are poor approximations. They both are likely be have unbound errors.

use rv::dist::{Gaussian, Empirical};
use rv::prelude::Rv;
use rv::misc::linspace;
use rand_xoshiro::Xoshiro256Plus;
use rand::SeedableRng;

let mut rng = Xoshiro256Plus::seed_from_u64(0xABCD);
let gen = Gaussian::standard();

let sample: Vec<f64> = gen.sample(1000, &mut rng);
let emp_dist = Empirical::new(sample);

let ln_f_err: Vec<f64> = linspace(emp_dist.range().0, emp_dist.range().1, 1000)
    .iter()
    .map(|x| {
        gen.ln_f(x) - emp_dist.ln_f(x)
    }).collect();

Implementations

impl Empirical[src]

pub fn new(xs: Vec<f64>) -> Self[src]

Create a new Empirical distribution with the given observed values

pub fn empcdfs(&self, values: &[f64]) -> Vec<f64>[src]

Compute the CDF of a number of values

pub fn pp(&self, other: &Self) -> (Vec<f64>, Vec<f64>)[src]

A utility for computing a P-P plot.

pub fn err(&self, other: &Self) -> f64[src]

Area between CDF-CDF (1-1) line

pub fn range(&self) -> &(f64, f64)[src]

Return the range of non-zero support for this distribution.

Trait Implementations

impl Cdf<f64> for Empirical[src]

impl Clone for Empirical[src]

impl Debug for Empirical[src]

impl Mean<f64> for Empirical[src]

impl PartialEq<Empirical> for Empirical[src]

impl PartialOrd<Empirical> for Empirical[src]

impl Rv<f64> for Empirical[src]

impl StructuralPartialEq for Empirical[src]

impl Variance<f64> for Empirical[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,