[][src]Trait compute::distributions::Distribution

pub trait Distribution: Send + Sync {
    pub fn sample(&self) -> f64;
pub fn update(&mut self, params: &[f64]); pub fn sample_vec(&self, n: usize) -> Vec<f64> { ... }
pub fn vector(&self, shape: usize) -> Array<f64, Ix1> { ... }
pub fn matrix(&self, shape: (usize, usize)) -> Array<f64, Ix2> { ... } }

The primary trait defining a probability distribution.

Required methods

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

Samples from the given probability distribution.

pub fn update(&mut self, params: &[f64])[src]

Loading content...

Provided methods

pub fn sample_vec(&self, n: usize) -> Vec<f64>[src]

Generates a vector of n randomly sampled values from the given probability distribution.

pub fn vector(&self, shape: usize) -> Array<f64, Ix1>[src]

Creates an 1d array with values sampled from the given distribution.

pub fn matrix(&self, shape: (usize, usize)) -> Array<f64, Ix2>[src]

Creates an 2d matrix with values sampled from the given distribution.

Loading content...

Implementors

impl Distribution for Bernoulli[src]

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

Samples from the given Bernoulli distribution.

impl Distribution for Beta[src]

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

Samples from the given Beta distribution using the Gamma distribution.

impl Distribution for ChiSquared[src]

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

Samples from the given Chi square distribution.

impl Distribution for DiscreteUniform[src]

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

Samples from the given discrete uniform distribution.

impl Distribution for Exponential[src]

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

Samples from the given Exponential distribution.

Remarks

Uses the inverse transform sampling method.

impl Distribution for Gamma[src]

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

Samples from the given Gamma distribution.

Remarks

Uses the algorithm from Marsaglia and Tsang 2000. Applies the squeeze method and has nearly constant average time for alpha >= 1.

impl Distribution for Normal[src]

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

Sample from the given Normal distribution.

impl Distribution for Poisson[src]

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

Samples from the given Poisson distribution. For lambda < 10.0, this is done with the direct (multiplication) method, and for lambda >= 10.0, this is done the PTRS transformed rejection method from Hoermann.

impl Distribution for Uniform[src]

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

Samples from the given Uniform distribution.

Loading content...