Struct rand::distributions::Cauchy
source · [−]pub struct Cauchy { /* private fields */ }
Expand description
The Cauchy distribution Cauchy(median, scale)
.
This distribution has a density function:
f(x) = 1 / (pi * scale * (1 + ((x - median) / scale)^2))
Example
use rand::distributions::{Cauchy, Distribution};
let cau = Cauchy::new(2.0, 5.0);
let v = cau.sample(&mut rand::thread_rng());
println!("{} is from a Cauchy(2, 5) distribution", v);
Implementations
Trait Implementations
sourceimpl Distribution<f64> for Cauchy
impl Distribution<f64> for Cauchy
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> f64
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
D: Distribution<T>,
R: Rng + 'a, type Item = T;
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
impl Copy for Cauchy
Auto Trait Implementations
impl RefUnwindSafe for Cauchy
impl Send for Cauchy
impl Sync for Cauchy
impl Unpin for Cauchy
impl UnwindSafe for Cauchy
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more