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
.
Implementations§
Trait Implementations§
source§impl<'de, F> Deserialize<'de> for Cauchy<F>
impl<'de, F> Deserialize<'de> for Cauchy<F>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl<F> Distribution<F> for Cauchy<F>
impl<F> Distribution<F> for Cauchy<F>
impl<F> Copy for Cauchy<F>
impl<F> StructuralPartialEq for Cauchy<F>
Auto Trait Implementations§
impl<F> Freeze for Cauchy<F>where
F: Freeze,
impl<F> RefUnwindSafe for Cauchy<F>where
F: RefUnwindSafe,
impl<F> Send for Cauchy<F>where
F: Send,
impl<F> Sync for Cauchy<F>where
F: Sync,
impl<F> Unpin for Cauchy<F>where
F: Unpin,
impl<F> UnwindSafe for Cauchy<F>where
F: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)