[−][src]Trait compute::distributions::Distribution
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]
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.
Implementors
impl Distribution for Bernoulli
[src]
pub fn sample(&self) -> f64
[src]
Samples from the given Bernoulli distribution.
pub fn update(&mut self, params: &[f64])
[src]
impl Distribution for Beta
[src]
pub fn sample(&self) -> f64
[src]
Samples from the given Beta distribution using the Gamma distribution.
pub fn update(&mut self, params: &[f64])
[src]
impl Distribution for ChiSquared
[src]
pub fn sample(&self) -> f64
[src]
Samples from the given Chi square distribution.
pub fn update(&mut self, params: &[f64])
[src]
impl Distribution for DiscreteUniform
[src]
pub fn sample(&self) -> f64
[src]
Samples from the given discrete uniform distribution.
pub fn update(&mut self, params: &[f64])
[src]
impl Distribution for Exponential
[src]
pub fn sample(&self) -> f64
[src]
Samples from the given Exponential distribution.
Remarks
Uses the inverse transform sampling method.
pub fn update(&mut self, params: &[f64])
[src]
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
.
pub fn update(&mut self, params: &[f64])
[src]
impl Distribution for Normal
[src]
pub fn sample(&self) -> f64
[src]
Sample from the given Normal distribution.
pub fn update(&mut self, params: &[f64])
[src]
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.