Skip to main content

TryRandomSampleFrom

Trait TryRandomSampleFrom 

Source
pub trait TryRandomSampleFrom: Sized {
    type Sample: RawRealTrait;
    type Error: Error;

    // Required method
    fn try_sample_from<D, R>(
        distribution: &D,
        rng: &mut R,
        precision_out: u32,
    ) -> Result<Self, Self::Error>
       where D: Distribution<Self::Sample>,
             R: Rng + ?Sized;
}
Expand description

A fallible conversion from a distribution sample into Self at a requested precision.

precision_out is interpreted by the target type. Fixed-precision targets such as f32 and f64 require their respective mantissa widths (24 and 53), while rug::Float uses it as the precision of the constructed value.

Required Associated Types§

Source

type Sample: RawRealTrait

Source

type Error: Error

The error returned when a sample cannot be converted or validated.

Required Methods§

Source

fn try_sample_from<D, R>( distribution: &D, rng: &mut R, precision_out: u32, ) -> Result<Self, Self::Error>
where D: Distribution<Self::Sample>, R: Rng + ?Sized,

Samples a value and converts it to Self at precision_out.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl TryRandomSampleFrom for Float

Available on crate feature rug only.
Source§

type Sample = f64

Source§

type Error = RawRealConversionError<f64, Float>

Source§

fn try_sample_from<D, R>( distribution: &D, rng: &mut R, precision_out: u32, ) -> Result<Self, Self::Error>
where D: Distribution<f64>, R: Rng + ?Sized,

Source§

impl TryRandomSampleFrom for f32

Source§

type Sample = f32

Source§

type Error = RawRealConversionError<f32, f32>

Source§

fn try_sample_from<D, R>( distribution: &D, rng: &mut R, precision_out: u32, ) -> Result<Self, Self::Error>
where D: Distribution<f32>, R: Rng + ?Sized,

Source§

impl TryRandomSampleFrom for f64

Source§

type Sample = f64

Source§

type Error = RawRealConversionError<f64, f64>

Source§

fn try_sample_from<D, R>( distribution: &D, rng: &mut R, precision_out: u32, ) -> Result<Self, Self::Error>
where D: Distribution<f64>, R: Rng + ?Sized,

Source§

impl<T> TryRandomSampleFrom for Complex<T>

Source§

type Sample = <T as TryRandomSampleFrom>::Sample

Source§

type Error = RandomSampleComplexErrors<T>

Source§

fn try_sample_from<D, R>( distribution: &D, rng: &mut R, precision_out: u32, ) -> Result<Self, Self::Error>
where D: Distribution<Self::Sample>, R: Rng + ?Sized,

Implementors§