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
templatewhose length equals the desired sample length. The contents are not read; only the shape matters. - Implementor must: sample each component independently from
rand_distr::StandardNormaland return a freshly allocated value of the same length astemplate. - Implementor must: advance
rngby exactly the number off64draws thatrand_distr::StandardNormalperforms per component, so that reproducibility is well-defined for fixed-seed RNGs across backends modulo iteration order.
Required Methods§
Sourcefn sample_standard_normal<R: Rng + ?Sized>(template: &Self, rng: &mut R) -> Self
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>where
StandardNormal: Distribution<F>,
Available on crate features ndarray_all and ndarray_v0_17 only.
impl<F: Scalar> SampleStandardNormal for Array1<F>where
StandardNormal: Distribution<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>where
StandardNormal: Distribution<F>,
Available on crate features faer_all and faer_v0_24 only.
impl<F: Scalar> SampleStandardNormal for Col<F>where
StandardNormal: Distribution<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>where
StandardNormal: Distribution<F>,
Available on crate feature nalgebra_all only.
impl<F: Scalar> SampleStandardNormal for DVector<F>where
StandardNormal: Distribution<F>,
Available on crate feature
nalgebra_all only.