Struct statrs::distribution::Cauchy
[−]
[src]
pub struct Cauchy { /* fields omitted */ }
Implements the Cauchy distribution, also known as the Lorentz distribution.
Examples
use statrs::distribution::{Cauchy, Continuous}; use statrs::statistics::Mode; let n = Cauchy::new(0.0, 1.0).unwrap(); assert_eq!(n.mode(), 0.0); assert_eq!(n.pdf(1.0), 0.1591549430918953357689);
Methods
impl Cauchy
[src]
fn new(location: f64, scale: f64) -> Result<Cauchy>
Constructs a new cauchy distribution with the given location and scale.
Errors
Returns an error if location or scale are NaN
or scale <= 0.0
Examples
use statrs::distribution::Cauchy; let mut result = Cauchy::new(0.0, 1.0); assert!(result.is_ok()); result = Cauchy::new(0.0, -1.0); assert!(result.is_err());
fn location(&self) -> f64
Returns the location of the cauchy distribution
Examples
use statrs::distribution::Cauchy; let n = Cauchy::new(0.0, 1.0).unwrap(); assert_eq!(n.location(), 0.0);
fn scale(&self) -> f64
Returns the scale of the cauchy distribution
Examples
use statrs::distribution::Cauchy; let n = Cauchy::new(0.0, 1.0).unwrap(); assert_eq!(n.scale(), 1.0);
Trait Implementations
impl Debug for Cauchy
[src]
impl Copy for Cauchy
[src]
impl Clone for Cauchy
[src]
fn clone(&self) -> Cauchy
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Cauchy
[src]
fn eq(&self, __arg_0: &Cauchy) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Cauchy) -> bool
This method tests for !=
.
impl Sample<f64> for Cauchy
[src]
fn sample<R: Rng>(&mut self, r: &mut R) -> f64
Generate a random sample from a cauchy
distribution using r
as the source of randomness.
Refer here for implementation details
impl IndependentSample<f64> for Cauchy
[src]
fn ind_sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random independent sample from a cauchy
distribution using r
as the source of randomness.
Refer here for implementation details
impl Distribution<f64> for Cauchy
[src]
fn sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random sample from the cauchy distribution
using r
as the source of randomness
Examples
use rand::StdRng; use statrs::distribution::{Cauchy, Distribution}; let mut r = rand::StdRng::new().unwrap(); let n = Cauchy::new(0.0, 1.0).unwrap(); print!("{}", n.sample::<StdRng>(&mut r));
impl Univariate<f64, f64> for Cauchy
[src]
fn cdf(&self, x: f64) -> f64
Calculates the cumulative distribution function for the
cauchy distribution at x
Formula
(1 / π) * arctan((x - x_0) / γ) + 0.5
where x_0
is the location and γ
is the scale
impl Min<f64> for Cauchy
[src]
fn min(&self) -> f64
Returns the minimum value in the domain of the cauchy distribution representable by a double precision float
Formula
NEG_INF
impl Max<f64> for Cauchy
[src]
fn max(&self) -> f64
Returns the maximum value in the domain of the cauchy distribution representable by a double precision float
Formula
INF
impl Entropy<f64> for Cauchy
[src]
impl Median<f64> for Cauchy
[src]
impl Mode<f64> for Cauchy
[src]
impl Continuous<f64, f64> for Cauchy
[src]
fn pdf(&self, x: f64) -> f64
Calculates the probability density function for the cauchy
distribution at x
Formula
1 / (πγ * (1 + ((x - x_0) / γ)^2))
where x_0
is the location and γ
is the scale
fn ln_pdf(&self, x: f64) -> f64
Calculates the log probability density function for the cauchy
distribution at x
Formula
ln(1 / (πγ * (1 + ((x - x_0) / γ)^2)))
where x_0
is the location and γ
is the scale