pub struct TUniform<T: UnsignedInteger> { /* private fields */ }Expand description
The distribution $TUniform(1, -2^b, 2^b)$ is defined as follows, any value in the interval $\left[-2^b, 2^b\right]$ is selected with probability $\frac{1}{2^{b+1}}$, with the two end points $-2^b$ and $2^b$ being selected with probability $\frac{1}{2^{b+2}}$.
Implementations§
Source§impl<T: UnsignedInteger> TUniform<T>
impl<T: UnsignedInteger> TUniform<T>
Sourcepub const fn new(bound_log2: u32) -> Self
pub const fn new(bound_log2: u32) -> Self
Construct a TUniform distribution see TUniform for behavior of randomly generated
values.
§Panics
Panics if bound_log2 is greater than the Scalar type number of bits minus two.
The reason for this is that with a higher bound_log2 it is impossible to distinguish
between $-2^{bound_log2}$ and $2^{bound_log2}$ because of the 2’s complement
representation of integers.
Sourcepub const fn try_new(bound_log2: u32) -> Result<Self, &'static str>
pub const fn try_new(bound_log2: u32) -> Result<Self, &'static str>
Construct a TUniform distribution see TUniform for behavior of randomly generated
values.
§Note
Returns an Err variant if bound_log2 is greater than the Scalar type number of bits
minus two.
The reason for this is that with a higher bound_log2 it is impossible to distinguish
between $-2^{bound_log2}$ and $2^{bound_log2}$ because of the 2’s complement
representation of integers.
pub const fn bound_log2(&self) -> u32
pub fn min_value_inclusive(&self) -> T::Signed
pub fn max_value_inclusive(&self) -> T::Signed
pub fn variance(&self, modulus: f64) -> Variance
Trait Implementations§
Source§impl<T> BoundedDistribution<<T as UnsignedInteger>::Signed> for TUniform<T>where
T: UnsignedInteger,
impl<T> BoundedDistribution<<T as UnsignedInteger>::Signed> for TUniform<T>where
T: UnsignedInteger,
Source§impl<'de, T: UnsignedInteger> Deserialize<'de> for TUniform<T>
impl<'de, T: UnsignedInteger> Deserialize<'de> for TUniform<T>
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>,
Source§impl RandomGenerable<TUniform<u128>> for u128
impl RandomGenerable<TUniform<u128>> for u128
type CustomModulus = u128
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
_: TUniform<u128>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, _: TUniform<u128>, ) -> Self
distribution.Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: TUniform<u128>,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: TUniform<u128>, custom_modulus: Self::CustomModulus, ) -> Self
Source§fn single_sample_success_probability(
_distribution: TUniform<u128>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( _distribution: TUniform<u128>, _modulus: Option<Self::CustomModulus>, ) -> f64
Source§fn single_sample_required_random_byte_count(
_: TUniform<u128>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( _: TUniform<u128>, _modulus: Option<Self::CustomModulus>, ) -> usize
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<TUniform<u16>> for u16
impl RandomGenerable<TUniform<u16>> for u16
type CustomModulus = u16
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
_: TUniform<u16>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, _: TUniform<u16>, ) -> Self
distribution.Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: TUniform<u16>,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: TUniform<u16>, custom_modulus: Self::CustomModulus, ) -> Self
Source§fn single_sample_success_probability(
_distribution: TUniform<u16>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( _distribution: TUniform<u16>, _modulus: Option<Self::CustomModulus>, ) -> f64
Source§fn single_sample_required_random_byte_count(
_: TUniform<u16>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( _: TUniform<u16>, _modulus: Option<Self::CustomModulus>, ) -> usize
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<TUniform<u32>> for u32
impl RandomGenerable<TUniform<u32>> for u32
type CustomModulus = u32
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
_: TUniform<u32>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, _: TUniform<u32>, ) -> Self
distribution.Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: TUniform<u32>,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: TUniform<u32>, custom_modulus: Self::CustomModulus, ) -> Self
Source§fn single_sample_success_probability(
_distribution: TUniform<u32>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( _distribution: TUniform<u32>, _modulus: Option<Self::CustomModulus>, ) -> f64
Source§fn single_sample_required_random_byte_count(
_: TUniform<u32>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( _: TUniform<u32>, _modulus: Option<Self::CustomModulus>, ) -> usize
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<TUniform<u64>> for u64
impl RandomGenerable<TUniform<u64>> for u64
type CustomModulus = u64
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
_: TUniform<u64>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, _: TUniform<u64>, ) -> Self
distribution.Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: TUniform<u64>,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: TUniform<u64>, custom_modulus: Self::CustomModulus, ) -> Self
Source§fn single_sample_success_probability(
_distribution: TUniform<u64>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( _distribution: TUniform<u64>, _modulus: Option<Self::CustomModulus>, ) -> f64
Source§fn single_sample_required_random_byte_count(
_: TUniform<u64>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( _: TUniform<u64>, _modulus: Option<Self::CustomModulus>, ) -> usize
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<TUniform<u8>> for u8
impl RandomGenerable<TUniform<u8>> for u8
type CustomModulus = u8
Source§fn generate_one<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
_: TUniform<u8>,
) -> Self
fn generate_one<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, _: TUniform<u8>, ) -> Self
distribution.Source§fn generate_one_custom_modulus<G: ByteRandomGenerator>(
generator: &mut RandomGenerator<G>,
distribution: TUniform<u8>,
custom_modulus: Self::CustomModulus,
) -> Self
fn generate_one_custom_modulus<G: ByteRandomGenerator>( generator: &mut RandomGenerator<G>, distribution: TUniform<u8>, custom_modulus: Self::CustomModulus, ) -> Self
Source§fn single_sample_success_probability(
_distribution: TUniform<u8>,
_modulus: Option<Self::CustomModulus>,
) -> f64
fn single_sample_success_probability( _distribution: TUniform<u8>, _modulus: Option<Self::CustomModulus>, ) -> f64
Source§fn single_sample_required_random_byte_count(
_: TUniform<u8>,
_modulus: Option<Self::CustomModulus>,
) -> usize
fn single_sample_required_random_byte_count( _: TUniform<u8>, _modulus: Option<Self::CustomModulus>, ) -> usize
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: UnsignedInteger> Serialize for TUniform<T>
impl<T: UnsignedInteger> Serialize for TUniform<T>
Source§impl<T: UnsignedInteger> Unversionize for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
impl<T: UnsignedInteger> Unversionize for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
Source§fn unversionize(
versioned: Self::VersionedOwned,
) -> Result<Self, UnversionizeError>
fn unversionize( versioned: Self::VersionedOwned, ) -> Result<Self, UnversionizeError>
Source§impl<T: UnsignedInteger> UnversionizeVec for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
impl<T: UnsignedInteger> UnversionizeVec for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
fn unversionize_vec( versioned: Self::VersionedVec, ) -> Result<Vec<Self>, UnversionizeError>
Source§impl<T: UnsignedInteger> Version for TUniform<T>where
u32: VersionizeOwned + Unversionize + Versionize,
PhantomData<T>: VersionizeOwned + Unversionize + Versionize,
impl<T: UnsignedInteger> Version for TUniform<T>where
u32: VersionizeOwned + Unversionize + Versionize,
PhantomData<T>: VersionizeOwned + Unversionize + Versionize,
Source§impl<T: UnsignedInteger> Versionize for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
impl<T: UnsignedInteger> Versionize for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
Source§type Versioned<'vers> = <TUniformVersions<T> as VersionsDispatch<TUniform<T>>>::Ref<'vers>
where
T: 'vers
type Versioned<'vers> = <TUniformVersions<T> as VersionsDispatch<TUniform<T>>>::Ref<'vers> where T: 'vers
Source§fn versionize(&self) -> Self::Versioned<'_>
fn versionize(&self) -> Self::Versioned<'_>
Source§impl<T: UnsignedInteger> VersionizeOwned for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
impl<T: UnsignedInteger> VersionizeOwned for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
type VersionedOwned = <TUniformVersions<T> as VersionsDispatch<TUniform<T>>>::Owned
Source§fn versionize_owned(self) -> Self::VersionedOwned
fn versionize_owned(self) -> Self::VersionedOwned
Source§impl<T: UnsignedInteger> VersionizeSlice for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
impl<T: UnsignedInteger> VersionizeSlice for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
type VersionedSlice<'vers> = Vec<<TUniform<T> as Versionize>::Versioned<'vers>> where T: 'vers
fn versionize_slice(slice: &[Self]) -> Self::VersionedSlice<'_>
Source§impl<T: UnsignedInteger> VersionizeVec for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
impl<T: UnsignedInteger> VersionizeVec for TUniform<T>where
TUniformVersions<T>: VersionsDispatch<Self>,
type VersionedVec = Vec<<TUniform<T> as VersionizeOwned>::VersionedOwned>
fn versionize_vec(vec: Vec<Self>) -> Self::VersionedVec
Source§impl<T: UnsignedInteger> VersionsDispatch<TUniform<T>> for TUniformVersions<T>
impl<T: UnsignedInteger> VersionsDispatch<TUniform<T>> for TUniformVersions<T>
impl<T: Copy + UnsignedInteger> Copy for TUniform<T>
impl<T: UnsignedInteger> Distribution for TUniform<T>
impl<T: Eq + UnsignedInteger> Eq for TUniform<T>
impl<T: UnsignedInteger> StructuralPartialEq for TUniform<T>
Auto Trait Implementations§
impl<T> Freeze for TUniform<T>
impl<T> RefUnwindSafe for TUniform<T>where
T: RefUnwindSafe,
impl<T> Send for TUniform<T>
impl<T> Sync for TUniform<T>
impl<T> Unpin for TUniform<T>where
T: Unpin,
impl<T> UnwindSafe for TUniform<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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>
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>
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