Struct rand_distr::StandardNormal
source · pub struct StandardNormal;
Expand description
Samples floating-point numbers according to the normal distribution
N(0, 1)
(a.k.a. a standard normal, or Gaussian). This is equivalent to
Normal::new(0.0, 1.0)
but faster.
See Normal
for the general normal distribution.
Implemented via the ZIGNOR variant1 of the Ziggurat method.
Example
use rand::prelude::*;
use rand_distr::StandardNormal;
let val: f64 = thread_rng().sample(StandardNormal);
println!("{}", val);
Jurgen A. Doornik (2005). An Improved Ziggurat Method to Generate Normal Random Samples. Nuffield College, Oxford ↩
Trait Implementations§
source§impl Clone for StandardNormal
impl Clone for StandardNormal
source§fn clone(&self) -> StandardNormal
fn clone(&self) -> StandardNormal
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for StandardNormal
impl Debug for StandardNormal
source§impl Distribution<f32> for StandardNormal
impl Distribution<f32> for StandardNormal
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f32
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f32
Generate a random value of
T
, using rng
as the source of randomness.source§impl Distribution<f64> for StandardNormal
impl Distribution<f64> for StandardNormal
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
Generate a random value of
T
, using rng
as the source of randomness.