Struct UniformFloat
pub struct UniformFloat<X> { /* private fields */ }
The back-end implementing UniformSampler for floating-point types.
Unless you are implementing UniformSampler for your own type, this type
should not be used directly, use Uniform instead.
Implementation notes
UniformFloat implementations convert RNG output to a float in the range
[1, 2) via transmutation, map this to [0, 1), then scale and translate
to the desired range. Values produced this way have what equals 23 bits of
random digits for an f32 and 52 for an f64.
Bias and range errors
Bias may be expected within the least-significant bit of the significand.
It is not guaranteed that exclusive limits of a range are respected; i.e.
when sampling the range [a, b) it is not guaranteed that b is never
sampled.
Trait Implementations
impl UniformSampler for UniformFloat<f32>
type X = f32;fn new<B1, B2>(low_b: B1, high_b: B2) -> Result<Self, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,fn new_inclusive<B1, B2>(low_b: B1, high_b: B2) -> Result<Self, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::Xfn sample_single<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R) -> Result<Self::X, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,fn sample_single_inclusive<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R) -> Result<Self::X, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,
impl UniformSampler for UniformFloat<f64>
type X = f64;fn new<B1, B2>(low_b: B1, high_b: B2) -> Result<Self, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,fn new_inclusive<B1, B2>(low_b: B1, high_b: B2) -> Result<Self, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Self::Xfn sample_single<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R) -> Result<Self::X, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,fn sample_single_inclusive<R: Rng + ?Sized, B1, B2>(low_b: B1, high_b: B2, rng: &mut R) -> Result<Self::X, Error> where B1: SampleBorrow<Self::X> + Sized, B2: SampleBorrow<Self::X> + Sized,
impl<'de, X> Deserialize<'de> for UniformFloat<X>
where
X: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where __D: Deserializer<'de>,
impl<X> Serialize for UniformFloat<X>
where
X: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where __S: Serializer,
impl<X: Clone> Clone for UniformFloat<X>
fn clone(&self) -> Self
impl<X: Copy> Copy for UniformFloat<X>
impl<X: Debug> Debug for UniformFloat<X>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<X: PartialEq> PartialEq for UniformFloat<X>
fn eq(&self, other: &Self) -> bool