[−][src]Struct rv::dist::Cauchy
Cauchy distribution over x in (-∞, ∞).
Example
use rv::prelude::*; let cauchy = Cauchy::new(1.2, 3.4).expect("Invalid params"); let ln_fx = cauchy.ln_pdf(&0.2_f64); // -2.4514716152673368 assert!((ln_fx + 2.4514716152673368).abs() < 1E-12);
Implementations
impl Cauchy
[src]
pub fn new(loc: f64, scale: f64) -> Result<Self, CauchyError>
[src]
Creates a new Cauchy distribution
Arguments
- loc: location, x0, in (-∞, ∞)
- scale: scale, γ, in (0, ∞)
pub fn new_unchecked(loc: f64, scale: f64) -> Self
[src]
Create a new Cauchy without checking whether the parameters are valid.
pub fn loc(&self) -> f64
[src]
Get the location parameter
Example
let c = Cauchy::new(0.1, 1.0).unwrap(); assert_eq!(c.loc(), 0.1);
pub fn set_loc(&mut self, loc: f64) -> Result<(), CauchyError>
[src]
Set the location parameter
Example
let mut c = Cauchy::new(0.1, 1.0).unwrap(); assert_eq!(c.loc(), 0.1); c.set_loc(2.0).unwrap(); assert_eq!(c.loc(), 2.0);
Will error for invalid parameters
assert!(c.set_loc(2.0).is_ok()); assert!(c.set_loc(std::f64::INFINITY).is_err()); assert!(c.set_loc(std::f64::NEG_INFINITY).is_err()); assert!(c.set_loc(std::f64::NAN).is_err());
pub fn set_loc_unchecked(&mut self, loc: f64)
[src]
Set the location parameter without input validation
pub fn scale(&self) -> f64
[src]
pub fn set_scale(&mut self, scale: f64) -> Result<(), CauchyError>
[src]
Set the scale parameter
Example
let mut c = Cauchy::new(0.1, 1.0).unwrap(); assert_eq!(c.scale(), 1.0); c.set_scale(2.1).unwrap(); assert_eq!(c.scale(), 2.1);
Will error for invalid scale.
assert!(c.set_scale(0.0).is_err()); assert!(c.set_scale(-1.0).is_err()); assert!(c.set_scale(std::f64::NAN).is_err()); assert!(c.set_scale(std::f64::INFINITY).is_err());
pub fn set_scale_unchecked(&mut self, scale: f64)
[src]
Set scale parameter without input validation
Trait Implementations
impl Cdf<f32> for Cauchy
[src]
impl Cdf<f64> for Cauchy
[src]
impl Clone for Cauchy
[src]
impl ContinuousDistr<f32> for Cauchy
[src]
impl ContinuousDistr<f64> for Cauchy
[src]
impl Debug for Cauchy
[src]
impl Default for Cauchy
[src]
impl Display for Cauchy
[src]
impl Entropy for Cauchy
[src]
impl<'_> From<&'_ Cauchy> for String
[src]
impl InverseCdf<f32> for Cauchy
[src]
fn invcdf(&self, p: f64) -> f32
[src]
fn quantile(&self, p: f64) -> X
[src]
fn interval(&self, p: f64) -> (X, X)
[src]
impl InverseCdf<f64> for Cauchy
[src]
fn invcdf(&self, p: f64) -> f64
[src]
fn quantile(&self, p: f64) -> X
[src]
fn interval(&self, p: f64) -> (X, X)
[src]
impl Median<f32> for Cauchy
[src]
impl Median<f64> for Cauchy
[src]
impl Mode<f32> for Cauchy
[src]
impl Mode<f64> for Cauchy
[src]
impl PartialEq<Cauchy> for Cauchy
[src]
impl Rv<f32> for Cauchy
[src]
fn ln_f(&self, x: &f32) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> f32
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<f32>
[src]
fn f(&self, x: &X) -> f64
[src]
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl Rv<f64> for Cauchy
[src]
fn ln_f(&self, x: &f64) -> f64
[src]
fn draw<R: Rng>(&self, rng: &mut R) -> f64
[src]
fn sample<R: Rng>(&self, n: usize, rng: &mut R) -> Vec<f64>
[src]
fn f(&self, x: &X) -> f64
[src]
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl StructuralPartialEq for Cauchy
[src]
impl Support<f32> for Cauchy
[src]
impl Support<f64> for Cauchy
[src]
Auto Trait Implementations
impl RefUnwindSafe for Cauchy
impl Send for Cauchy
impl Sync for Cauchy
impl Unpin for Cauchy
impl UnwindSafe for Cauchy
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<Fx, X> Cdf<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Cdf<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Cdf<X>,
impl<Fx, X> ContinuousDistr<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: ContinuousDistr<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: ContinuousDistr<X>,
impl<Fx> Entropy for Fx where
Fx: Deref,
<Fx as Deref>::Target: Entropy,
[src]
Fx: Deref,
<Fx as Deref>::Target: Entropy,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<Fx, X> InverseCdf<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: InverseCdf<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: InverseCdf<X>,
fn invcdf(&Self, f64) -> X
[src]
fn quantile(&Self, f64) -> X
[src]
fn interval(&Self, f64) -> (X, X)
[src]
impl<Fx, X> Median<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Median<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Median<X>,
impl<Fx, X> Mode<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Mode<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Mode<X>,
impl<Fx, X> Rv<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Rv<X>,
fn ln_f(&Self, &X) -> f64
[src]
fn f(&Self, &X) -> f64
[src]
fn draw<R>(&Self, &mut R) -> X where
R: Rng,
[src]
R: Rng,
fn sample<R>(&Self, usize, &mut R) -> Vec<X> where
R: Rng,
[src]
R: Rng,
fn sample_stream<'r, R: Rng>(
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
[src]
&'r self,
rng: &'r mut R
) -> Box<dyn Iterator<Item = X> + 'r>
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<Fx, X> Support<X> for Fx where
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
[src]
Fx: Deref,
<Fx as Deref>::Target: Support<X>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,