Skip to main content

Gaussian

Struct Gaussian 

Source
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: T

The standard deviation of the distribution.

§mean: T

The mean of the distribution.

Implementations§

Source§

impl Gaussian<f64>

Source

pub const fn from_standard_dev(std: StandardDev, mean: f64) -> Self

Source

pub fn from_dispersion_parameter( dispersion: impl DispersionParameter, mean: f64, ) -> Self

Source

pub const fn standard_dev(&self) -> StandardDev

Trait Implementations§

Source§

impl<T: Clone + FloatingPoint> Clone for Gaussian<T>

Source§

fn clone(&self) -> Gaussian<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + FloatingPoint> Debug for Gaussian<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: PartialEq + FloatingPoint> PartialEq for Gaussian<T>

Source§

fn eq(&self, other: &Gaussian<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl RandomGenerable<Gaussian<f32>> for (f32, f32)

Source§

type CustomModulus = f32

Source§

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

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

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

Generate a value from distribution modulo the given custom_modulus. Read more
Source§

fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )

Source§

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)
where Torus: FromTorus<f64>,

Source§

type CustomModulus = Torus

Source§

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

Generate a value from distribution modulo the given custom_modulus. Read more
Source§

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

Return how many bytes coming from a CSPRNG are required to generate one sample even if that generation can fail. Read more
Source§

fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )

Source§

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)

Source§

type CustomModulus = f64

Source§

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

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

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

Generate a value from distribution modulo the given custom_modulus. Read more
Source§

fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )

Source§

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
where Torus: FromTorus<f64>,

Source§

type CustomModulus = Torus

Source§

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

Generate a value from distribution modulo the given custom_modulus. Read more
Source§

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

Return how many bytes coming from a CSPRNG are required to generate one sample even if that generation can fail. Read more
Source§

fn fill_slice<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], )

Source§

fn fill_slice_custom_mod<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: D, slice: &mut [Self], custom_modulus: Self::CustomModulus, )

Source§

impl<T> Serialize for Gaussian<T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: FloatingPoint> Unversionize for Gaussian<T>

Source§

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>

Source§

impl<T> Version for Gaussian<T>

Source§

type Ref<'vers> = GaussianVersion<'vers, T> where T: 'vers

Source§

type Owned = GaussianVersionOwned<T>

Source§

impl<T: FloatingPoint> Versionize for Gaussian<T>

Source§

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<'_>

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>

Source§

type VersionedOwned = <GaussianVersions<T> as VersionsDispatch<Gaussian<T>>>::Owned

Source§

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>

Source§

type VersionedSlice<'vers> = Vec<<Gaussian<T> as Versionize>::Versioned<'vers>> where T: 'vers

Source§

fn versionize_slice(slice: &[Self]) -> Self::VersionedSlice<'_>

Source§

impl<T: FloatingPoint> VersionizeVec for Gaussian<T>

Source§

impl<T: FloatingPoint> VersionsDispatch<Gaussian<T>> for GaussianVersions<T>
where Gaussian<T>: Version,

Source§

type Ref<'vers> = GaussianVersionsDispatch<'vers, T> where T: 'vers

Source§

type Owned = GaussianVersionsDispatchOwned<T>

Source§

impl<T: Copy + FloatingPoint> Copy for Gaussian<T>

Source§

impl<T: FloatingPoint> Distribution for Gaussian<T>

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Input, Output> CastInto<Output> for Input
where Output: CastFrom<Input>,

Source§

fn cast_into(self) -> Output

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,