pub struct Generator<B: BitGenerator> { /* private fields */ }Expand description
Generator for random number streams with modern interface
This class is modeled after NumPy’s Generator class, which is the modern interface for random number generation in NumPy.
Implementations§
Source§impl<B: BitGenerator> Generator<B>
impl<B: BitGenerator> Generator<B>
Sourcepub fn random<T>(&self, shape: &[usize]) -> Result<Array<T>>
pub fn random<T>(&self, shape: &[usize]) -> Result<Array<T>>
Generate uniform random values in [0, 1)
Sourcepub fn integers<T: Clone + PartialOrd + SampleUniform + Into<i64> + TryFrom<i64> + ToPrimitive>(
&self,
low: T,
high: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn integers<T: Clone + PartialOrd + SampleUniform + Into<i64> + TryFrom<i64> + ToPrimitive>( &self, low: T, high: T, shape: &[usize], ) -> Result<Array<T>>
Sourcepub fn normal<T: Float + NumCast + Clone + Debug + Display>(
&self,
mean: T,
std: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn normal<T: Float + NumCast + Clone + Debug + Display>( &self, mean: T, std: T, shape: &[usize], ) -> Result<Array<T>>
Generate random values from a normal (Gaussian) distribution
Sourcepub fn standard_normal<T: Float + NumCast + Clone + Debug + Display>(
&self,
shape: &[usize],
) -> Result<Array<T>>
pub fn standard_normal<T: Float + NumCast + Clone + Debug + Display>( &self, shape: &[usize], ) -> Result<Array<T>>
Generate a standard normal distribution
Sourcepub fn lognormal<T: Float + NumCast + Clone + Debug + Display>(
&self,
mean: T,
sigma: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn lognormal<T: Float + NumCast + Clone + Debug + Display>( &self, mean: T, sigma: T, shape: &[usize], ) -> Result<Array<T>>
Generate random values from a log-normal distribution
Sourcepub fn beta<T: Float + NumCast + Clone + Debug + Display>(
&self,
a: T,
b: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn beta<T: Float + NumCast + Clone + Debug + Display>( &self, a: T, b: T, shape: &[usize], ) -> Result<Array<T>>
Generate random values from a Beta distribution
Sourcepub fn chisquare<T: Float + NumCast + Clone + Debug + Display>(
&self,
df: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn chisquare<T: Float + NumCast + Clone + Debug + Display>( &self, df: T, shape: &[usize], ) -> Result<Array<T>>
Generate random values from a Chi-Square distribution
Sourcepub fn gamma<T: Float + NumCast + Clone + Debug + Display>(
&self,
shape_param: T,
scale: T,
size_shape: &[usize],
) -> Result<Array<T>>
pub fn gamma<T: Float + NumCast + Clone + Debug + Display>( &self, shape_param: T, scale: T, size_shape: &[usize], ) -> Result<Array<T>>
Generate random values from a gamma distribution
Sourcepub fn exponential<T: Float + NumCast + Clone + Debug + Display>(
&self,
scale: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn exponential<T: Float + NumCast + Clone + Debug + Display>( &self, scale: T, shape: &[usize], ) -> Result<Array<T>>
Generate random values from an exponential distribution
Sourcepub fn weibull<T: Float + NumCast + Clone + Debug + Display>(
&self,
shape_param: T,
scale: T,
size_shape: &[usize],
) -> Result<Array<T>>
pub fn weibull<T: Float + NumCast + Clone + Debug + Display>( &self, shape_param: T, scale: T, size_shape: &[usize], ) -> Result<Array<T>>
Generate random values from a Weibull distribution
Sourcepub fn uniform<T: Clone + PartialOrd + SampleUniform + ToPrimitive + NumCast>(
&self,
low: T,
high: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn uniform<T: Clone + PartialOrd + SampleUniform + ToPrimitive + NumCast>( &self, low: T, high: T, shape: &[usize], ) -> Result<Array<T>>
Generate random values from a uniform distribution
Sourcepub fn bernoulli<T: Float + NumCast + Clone + Debug + Display>(
&self,
p: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn bernoulli<T: Float + NumCast + Clone + Debug + Display>( &self, p: T, shape: &[usize], ) -> Result<Array<T>>
Generate binary random values with given probability of success
Sourcepub fn poisson<T: NumCast + Clone + Debug>(
&self,
lam: f64,
shape: &[usize],
) -> Result<Array<T>>
pub fn poisson<T: NumCast + Clone + Debug>( &self, lam: f64, shape: &[usize], ) -> Result<Array<T>>
Generate random values from a Poisson distribution
Sourcepub fn binomial<T: NumCast + Clone + Debug>(
&self,
n: u64,
p: f64,
shape: &[usize],
) -> Result<Array<T>>
pub fn binomial<T: NumCast + Clone + Debug>( &self, n: u64, p: f64, shape: &[usize], ) -> Result<Array<T>>
Generate random values from a binomial distribution
Sourcepub fn integers_simple<T: Clone + PartialOrd + SampleUniform + NumCast>(
&self,
low: T,
high: T,
shape: &[usize],
) -> Result<Array<T>>
pub fn integers_simple<T: Clone + PartialOrd + SampleUniform + NumCast>( &self, low: T, high: T, shape: &[usize], ) -> Result<Array<T>>
Sourcepub fn bit_generator(&self) -> Result<MutexGuard<'_, B>>
pub fn bit_generator(&self) -> Result<MutexGuard<'_, B>>
Access the underlying bit generator
Auto Trait Implementations§
impl<B> Freeze for Generator<B>
impl<B> RefUnwindSafe for Generator<B>
impl<B> Send for Generator<B>where
B: Send,
impl<B> Sync for Generator<B>where
B: Send,
impl<B> Unpin for Generator<B>
impl<B> UnsafeUnpin for Generator<B>
impl<B> UnwindSafe for Generator<B>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.