pub struct McSampler { /* private fields */ }Expand description
Monte Carlo sampler supporting multiple probability distributions.
Uses an internal LCG RNG; set the seed for reproducibility.
Implementations§
Source§impl McSampler
impl McSampler
Sourcepub fn uniform_range(&mut self, a: f64, b: f64) -> f64
pub fn uniform_range(&mut self, a: f64, b: f64) -> f64
Samples from Uniform(a, b).
Sourcepub fn exponential(&mut self, lambda: f64) -> f64
pub fn exponential(&mut self, lambda: f64) -> f64
Samples from Exponential(lambda): pdf = lambda * exp(-lambda * x).
Sourcepub fn poisson(&mut self, lambda: f64) -> u64
pub fn poisson(&mut self, lambda: f64) -> u64
Samples from Poisson(lambda) using Knuth’s algorithm.
Sourcepub fn beta(&mut self, alpha: f64, beta: f64) -> f64
pub fn beta(&mut self, alpha: f64, beta: f64) -> f64
Samples from Beta(alpha, beta) using Johnk’s method.
Sourcepub fn gamma(&mut self, shape: f64, scale: f64) -> f64
pub fn gamma(&mut self, shape: f64, scale: f64) -> f64
Samples from Gamma(shape, scale) using Marsaglia-Tsang method.
Auto Trait Implementations§
impl Freeze for McSampler
impl RefUnwindSafe for McSampler
impl Send for McSampler
impl Sync for McSampler
impl Unpin for McSampler
impl UnsafeUnpin for McSampler
impl UnwindSafe for McSampler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.