Skip to main content

SampleStandardNormal

Trait SampleStandardNormal 

Source
pub trait SampleStandardNormal: Sized {
    // Required method
    fn sample_standard_normal<R: Rng + ?Sized>(
        template: &Self,
        rng: &mut R,
    ) -> Self;
}
Expand description

Per-component standard-normal sample. Returns a fresh value of the same shape as template with each component drawn independently from N(0, 1).

The vehicle for CMA-ES sampling: z_k ~ N(0, I) (Hansen 2016 eq. 38) composed with y_k = B D z_k (eq. 39) gives y_k ~ N(0, C).

§Contract

  • Caller must: pass a template whose length equals the desired sample length. The contents are not read; only the shape matters.
  • Implementor must: sample each component independently from rand_distr::StandardNormal and return a freshly allocated value of the same length as template.
  • Implementor must: advance rng by exactly the number of f64 draws that rand_distr::StandardNormal performs per component, so that reproducibility is well-defined for fixed-seed RNGs across backends modulo iteration order.

Required Methods§

Source

fn sample_standard_normal<R: Rng + ?Sized>(template: &Self, rng: &mut R) -> Self

Sample a fresh value with each component drawn from N(0, 1). template provides the shape (len); its values are unused.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl<F: Scalar> SampleStandardNormal for Array1<F>

Available on crate features ndarray_all and ndarray_v0_17 only.
§

fn sample_standard_normal<R: Rng + ?Sized>(template: &Self, rng: &mut R) -> Self

§

impl<F: Scalar> SampleStandardNormal for Col<F>

Available on crate features faer_all and faer_v0_24 only.
§

fn sample_standard_normal<R: Rng + ?Sized>(template: &Self, rng: &mut R) -> Self

§

impl<F: Scalar> SampleStandardNormal for DVector<F>

Available on crate feature nalgebra_all only.
§

fn sample_standard_normal<G: Rng + ?Sized>(template: &Self, rng: &mut G) -> Self

Source§

impl<F: Scalar> SampleStandardNormal for Vec<F>

Source§

fn sample_standard_normal<R: Rng + ?Sized>(template: &Self, rng: &mut R) -> Self

Implementors§