pub struct Gaussian<T: FloatingPoint> {
pub std: T,
pub mean: T,
}Expand description
A distribution type representing random sampling of floating point numbers, following a gaussian distribution.
Fields§
§std: TThe standard deviation of the distribution.
mean: TThe mean of the distribution.
Implementations§
Source§impl Gaussian<f64>
impl Gaussian<f64>
pub const fn from_standard_dev(std: StandardDev, mean: f64) -> Self
pub fn from_dispersion_parameter( dispersion: impl DispersionParameter, mean: f64, ) -> Self
pub const fn standard_dev(&self) -> StandardDev
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Gaussian<T>where
T: Deserialize<'de> + FloatingPoint,
impl<'de, T> Deserialize<'de> for Gaussian<T>where
T: Deserialize<'de> + FloatingPoint,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl RandomGenerable<Gaussian<f32>> for (f32, f32)
impl RandomGenerable<Gaussian<f32>> for (f32, f32)
type CustomModulus = f32
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
_: Gaussian<f32>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, _: Gaussian<f32>, ) -> Self
Generate a value from
distribution.Source§fn single_sample_success_probability(
_distribution: Gaussian<f32>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( _distribution: Gaussian<f32>, _modulus: Option<Self::CustomModulus>, ) -> f64
Return the probability to successfully generate a sample from the given distribution for the
type the trait is implemented on. Read more
Source§fn single_sample_required_random_byte_count(
_distribution: Gaussian<f32>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( _distribution: Gaussian<f32>, _modulus: Option<Self::CustomModulus>, ) -> usize
Return how many bytes coming from a CSPRNG are required to generate one sample even if that
generation can fail. Read more
Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: D,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, custom_modulus: Self::CustomModulus, ) -> Self
fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )
fn fill_slice_custom_mod<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], custom_modulus: Self::CustomModulus, )
Source§impl<Torus> RandomGenerable<Gaussian<f64>> for (Torus, Torus)
impl<Torus> RandomGenerable<Gaussian<f64>> for (Torus, Torus)
type CustomModulus = Torus
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: Gaussian<f64>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: Gaussian<f64>, ) -> Self
Generate a value from
distribution.Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: Gaussian<f64>,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: Gaussian<f64>, custom_modulus: Self::CustomModulus, ) -> Self
Source§fn single_sample_success_probability(
distribution: Gaussian<f64>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( distribution: Gaussian<f64>, _modulus: Option<Self::CustomModulus>, ) -> f64
Return the probability to successfully generate a sample from the given distribution for the
type the trait is implemented on. Read more
Source§fn single_sample_required_random_byte_count(
distribution: Gaussian<f64>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( distribution: Gaussian<f64>, _modulus: Option<Self::CustomModulus>, ) -> usize
Return how many bytes coming from a CSPRNG are required to generate one sample even if that
generation can fail. Read more
fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )
fn fill_slice_custom_mod<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], custom_modulus: Self::CustomModulus, )
Source§impl RandomGenerable<Gaussian<f64>> for (f64, f64)
impl RandomGenerable<Gaussian<f64>> for (f64, f64)
type CustomModulus = f64
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
_: Gaussian<f64>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, _: Gaussian<f64>, ) -> Self
Generate a value from
distribution.Source§fn single_sample_success_probability(
_distribution: Gaussian<f64>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( _distribution: Gaussian<f64>, _modulus: Option<Self::CustomModulus>, ) -> f64
Return the probability to successfully generate a sample from the given distribution for the
type the trait is implemented on. Read more
Source§fn single_sample_required_random_byte_count(
_distribution: Gaussian<f64>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( _distribution: Gaussian<f64>, _modulus: Option<Self::CustomModulus>, ) -> usize
Return how many bytes coming from a CSPRNG are required to generate one sample even if that
generation can fail. Read more
Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: D,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, custom_modulus: Self::CustomModulus, ) -> Self
fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )
fn fill_slice_custom_mod<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], custom_modulus: Self::CustomModulus, )
Source§impl<Torus> RandomGenerable<Gaussian<f64>> for Torus
impl<Torus> RandomGenerable<Gaussian<f64>> for Torus
type CustomModulus = Torus
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: Gaussian<f64>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: Gaussian<f64>, ) -> Self
Generate a value from
distribution.Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: Gaussian<f64>,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: Gaussian<f64>, custom_modulus: Self::CustomModulus, ) -> Self
Source§fn single_sample_success_probability(
distribution: Gaussian<f64>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( distribution: Gaussian<f64>, _modulus: Option<Self::CustomModulus>, ) -> f64
Return the probability to successfully generate a sample from the given distribution for the
type the trait is implemented on. Read more
Source§fn single_sample_required_random_byte_count(
distribution: Gaussian<f64>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( distribution: Gaussian<f64>, _modulus: Option<Self::CustomModulus>, ) -> usize
Return how many bytes coming from a CSPRNG are required to generate one sample even if that
generation can fail. Read more
fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )
fn fill_slice_custom_mod<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], custom_modulus: Self::CustomModulus, )
Source§impl<T: FloatingPoint> Unversionize for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
impl<T: FloatingPoint> Unversionize for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
Source§fn unversionize(
versioned: Self::VersionedOwned,
) -> Result<Self, UnversionizeError>
fn unversionize( versioned: Self::VersionedOwned, ) -> Result<Self, UnversionizeError>
Creates an object from a versioned enum, and eventually upgrades from previous
variants.
Source§impl<T: FloatingPoint> UnversionizeVec for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
impl<T: FloatingPoint> UnversionizeVec for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
fn unversionize_vec( versioned: Self::VersionedVec, ) -> Result<Vec<Self>, UnversionizeError>
Source§impl<T: FloatingPoint> Versionize for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
impl<T: FloatingPoint> Versionize for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
Source§type Versioned<'vers> = <GaussianVersions<T> as VersionsDispatch<Gaussian<T>>>::Ref<'vers>
where
T: 'vers
type Versioned<'vers> = <GaussianVersions<T> as VersionsDispatch<Gaussian<T>>>::Ref<'vers> where T: 'vers
The equivalent versioned type. It should have a variant for each version.
It may own the underlying data or only hold a read-only reference to it.
Source§fn versionize(&self) -> Self::Versioned<'_>
fn versionize(&self) -> Self::Versioned<'_>
Wraps the object into a versioned enum with a variant for each version. This will
use references on the underlying types if possible.
Source§impl<T: FloatingPoint> VersionizeOwned for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
impl<T: FloatingPoint> VersionizeOwned for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
type VersionedOwned = <GaussianVersions<T> as VersionsDispatch<Gaussian<T>>>::Owned
Source§fn versionize_owned(self) -> Self::VersionedOwned
fn versionize_owned(self) -> Self::VersionedOwned
Wraps the object into a versioned enum with a variant for each version. This will
clone the underlying types.
Source§impl<T: FloatingPoint> VersionizeSlice for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
impl<T: FloatingPoint> VersionizeSlice for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
type VersionedSlice<'vers> = Vec<<Gaussian<T> as Versionize>::Versioned<'vers>> where T: 'vers
fn versionize_slice(slice: &[Self]) -> Self::VersionedSlice<'_>
Source§impl<T: FloatingPoint> VersionizeVec for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
impl<T: FloatingPoint> VersionizeVec for Gaussian<T>where
GaussianVersions<T>: VersionsDispatch<Self>,
type VersionedVec = Vec<<Gaussian<T> as VersionizeOwned>::VersionedOwned>
fn versionize_vec(vec: Vec<Self>) -> Self::VersionedVec
Source§impl<T: FloatingPoint> VersionsDispatch<Gaussian<T>> for GaussianVersions<T>
impl<T: FloatingPoint> VersionsDispatch<Gaussian<T>> for GaussianVersions<T>
impl<T: Copy + FloatingPoint> Copy for Gaussian<T>
impl<T: FloatingPoint> Distribution for Gaussian<T>
impl<T: FloatingPoint> StructuralPartialEq for Gaussian<T>
Auto Trait Implementations§
impl<T> Freeze for Gaussian<T>where
T: Freeze,
impl<T> RefUnwindSafe for Gaussian<T>where
T: RefUnwindSafe,
impl<T> Send for Gaussian<T>
impl<T> Sync for Gaussian<T>
impl<T> Unpin for Gaussian<T>where
T: Unpin,
impl<T> UnwindSafe for Gaussian<T>where
T: UnwindSafe,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more