pub struct Cauchy { /* private fields */ }
Expand description
A Cauchy distribution.
The Cauchy distribution (also known as Lorentz or Cauchy–Lorentz
distribution) is a continuous probability distribution with a location
parameter x_0
, a scale parameter gamma > 0
, and the following
probability density function:
p(x) = 1 / (pi * gamma * (1 + ((x - x_0) / gamma)^2))
.
The distribution is long tailed and has no mean or variance. It is unimodal
with the mode at x_0
, around which it is symmetric.
Create a Cauchy distribution with location x_0
and scale gamma
.
It should hold that gamma > 0
.
Return the location parameter.
107
108
109
110
111
112
113
114
115
fn sample<S>(&self, source: &mut S) -> f64
where
S: Source,
{
let gaussian = distribution::Gaussian::new(0.0, 1.0);
let a = gaussian.sample(source);
let b = gaussian.sample(source);
self.x_0() + self.gamma() * a / (b.abs() + f64::MIN_POSITIVE)
}
Return the scale parameter.
107
108
109
110
111
112
113
114
115
fn sample<S>(&self, source: &mut S) -> f64
where
S: Source,
{
let gaussian = distribution::Gaussian::new(0.0, 1.0);
let a = gaussian.sample(source);
let b = gaussian.sample(source);
self.x_0() + self.gamma() * a / (b.abs() + f64::MIN_POSITIVE)
}
Performs copy-assignment from
source
.
Read more
Compute the probability density function.
Formats the value using the given formatter.
Read more
The type of outcomes.
Compute the cumulative distribution function.
Compute the inverse of the cumulative distribution function.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
Uses borrowed data to replace owned data, usually by cloning.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.