pub struct Cauchy<F>{ /* private fields */ }
Expand description
The Cauchy distribution Cauchy(x₀, γ)
.
The Cauchy distribution is a continuous probability distribution with
parameters x₀
(median) and γ
(scale).
It describes the distribution of the ratio of two independent
normally distributed random variables with means x₀
and scales γ
.
In other words, if X
and Y
are independent normally distributed
random variables with means x₀
and scales γ
, respectively, then
X / Y
is Cauchy(x₀, γ)
distributed.
§Density function
f(x) = 1 / (π * γ * (1 + ((x - x₀) / γ)²))
§Plot
The plot illustrates the Cauchy distribution with various values of x₀
and γ
.
Note how the median parameter x₀
shifts the distribution along the x-axis,
and how the scale γ
changes the density around the median.
The standard Cauchy distribution is the special case with x₀ = 0
and γ = 1
,
which corresponds to the ratio of two StandardNormal
distributions.
§Example
use rand_distr::{Cauchy, Distribution};
let cau = Cauchy::new(2.0, 5.0).unwrap();
let v = cau.sample(&mut rand::rng());
println!("{} is from a Cauchy(2, 5) distribution", v);
§Notes
Note that at least for f32
, results are not fully portable due to minor
differences in the target system’s tan implementation, tanf
.