Struct rand_distr::Cauchy
source · pub struct Cauchy<F>where
F: Float + FloatConst,
Standard: Distribution<F>,{ /* 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))
Note that at least for f32
, results are not fully portable due to minor
differences in the target system’s tan implementation, tanf
.
Example
use rand_distr::{Cauchy, Distribution};
let cau = Cauchy::new(2.0, 5.0).unwrap();
let v = cau.sample(&mut rand::thread_rng());
println!("{} is from a Cauchy(2, 5) distribution", v);
Implementations§
Trait Implementations§
source§impl<F> Clone for Cauchy<F>where
F: Float + FloatConst + Clone,
Standard: Distribution<F>,
impl<F> Clone for Cauchy<F>where
F: Float + FloatConst + Clone,
Standard: Distribution<F>,
source§impl<F> Debug for Cauchy<F>where
F: Float + FloatConst + Debug,
Standard: Distribution<F>,
impl<F> Debug for Cauchy<F>where
F: Float + FloatConst + Debug,
Standard: Distribution<F>,
source§impl<F> Distribution<F> for Cauchy<F>where
F: Float + FloatConst,
Standard: Distribution<F>,
impl<F> Distribution<F> for Cauchy<F>where
F: Float + FloatConst,
Standard: Distribution<F>,
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> F
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> F
Generate a random value of
T
, using rng
as the source of randomness.