[][src]Struct rv::dist::Kumaraswamy

pub struct Kumaraswamy { /* fields omitted */ }

Kumaraswamy distribution, Kumaraswamy(α, β) over x in (0, 1).

Examples

The relationship between the CDF and the inverse CDF.

let kuma = Kumaraswamy::new(2.1, 3.4).unwrap();

let x = 0.6_f64;
let p: f64 = kuma.cdf(&x);
let y: f64 = kuma.invcdf(p);

assert::close(x, y, 1E-10);

Kumaraswamy(a, 1) is equivalent to Beta(a, 1) and Kumaraswamy(1, b) is equivalent to Beta(1, b)

let kuma = Kumaraswamy::new(1.0, 3.5).unwrap();
let beta = Beta::new(1.0, 3.5).unwrap();

let xs = rv::misc::linspace(0.1, 0.9, 10);

for x in xs.iter() {
    assert::close(kuma.f(x), beta.f(x), 1E-10);
}

Methods

impl Kumaraswamy[src]

pub fn new(a: f64, b: f64) -> Result<Self, KumaraswamyError>[src]

Create a Beta distribution with even density over (0, 1).

Example


let kuma_good = Kumaraswamy::new(1.0, 1.0);
assert!(kuma_good.is_ok());

// Invalid negative parameter
let kuma_bad  = Kumaraswamy::new(-5.0, 1.0);
assert!(kuma_bad.is_err());

pub fn new_unchecked(a: f64, b: f64) -> Self[src]

Creates a new Kumaraswamy without checking whether the parameters are valid.

pub fn uniform() -> Self[src]

Create a Kumaraswamy distribution with even density over (0, 1).

Example

let kuma = Kumaraswamy::uniform();
assert_eq!(kuma, Kumaraswamy::new(1.0, 1.0).unwrap());

pub fn centered(a: f64) -> Result<Self, KumaraswamyError>[src]

Create a Kumaraswamy distribution with median 0.5

Notes

The distribution will not necessarily be symmetrical about x = 0.5, i.e., for c < 0.5, f(0.5 - c) may not equal f(0.5 + c).

Examples

// Bowl-shaped
let kuma_1 = Kumaraswamy::centered(0.5).unwrap();
let median_1: f64 = kuma_1.median().unwrap();
assert::close(median_1, 0.5, 1E-10);
assert::close(kuma_1.cdf(&0.5), 0.5, 1E-10);
assert::close(kuma_1.b(), 0.5644763825137, 1E-10);

// Cone-shaped
let kuma_2 = Kumaraswamy::centered(2.0).unwrap();
let median_2: f64 = kuma_2.median().unwrap();
assert::close(median_2, 0.5, 1E-10);
assert::close(kuma_2.cdf(&0.5), 0.5, 1E-10);
assert::close(kuma_2.b(), 2.409420839653209, 1E-10);

The PDF will most likely not be symmetrical about 0.5

fn absolute_error(a: f64, b: f64) -> f64 {
    (a - b).abs()
}

let kuma = Kumaraswamy::centered(2.0).unwrap();
assert!(absolute_error(kuma.f(&0.1), kuma.f(&0.9)) > 1E-8);

pub fn a(&self) -> f64[src]

Get the a parameter

Example

let kuma = Kumaraswamy::new(1.0, 5.0).unwrap();
assert_eq!(kuma.a(), 1.0);

pub fn b(&self) -> f64[src]

Get the b parameter

Example

let kuma = Kumaraswamy::new(1.0, 5.0).unwrap();
assert_eq!(kuma.b(), 5.0);

pub fn set_a(&mut self, a: f64)[src]

pub fn set_b(&mut self, b: f64)[src]

Trait Implementations

impl Cdf<f32> for Kumaraswamy[src]

impl Cdf<f64> for Kumaraswamy[src]

impl Clone for Kumaraswamy[src]

impl ContinuousDistr<f32> for Kumaraswamy[src]

impl ContinuousDistr<f64> for Kumaraswamy[src]

impl Debug for Kumaraswamy[src]

impl Default for Kumaraswamy[src]

impl Display for Kumaraswamy[src]

impl Entropy for Kumaraswamy[src]

impl<'_> From<&'_ Kumaraswamy> for String[src]

impl InverseCdf<f32> for Kumaraswamy[src]

impl InverseCdf<f64> for Kumaraswamy[src]

impl Mean<f32> for Kumaraswamy[src]

impl Mean<f64> for Kumaraswamy[src]

impl Median<f32> for Kumaraswamy[src]

impl Median<f64> for Kumaraswamy[src]

impl Mode<f32> for Kumaraswamy[src]

impl Mode<f64> for Kumaraswamy[src]

impl PartialEq<Kumaraswamy> for Kumaraswamy[src]

impl Rv<f32> for Kumaraswamy[src]

impl Rv<f64> for Kumaraswamy[src]

impl Support<f32> for Kumaraswamy[src]

impl Support<f64> for Kumaraswamy[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Fx, X> Cdf<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Cdf<X>, 
[src]

impl<Fx, X> ContinuousDistr<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: ContinuousDistr<X>, 
[src]

impl<Fx> Entropy for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Entropy
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<Fx, X> InverseCdf<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: InverseCdf<X>, 
[src]

impl<Fx, X> Mean<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Mean<X>, 
[src]

impl<Fx, X> Median<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Median<X>, 
[src]

impl<Fx, X> Mode<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Mode<X>, 
[src]

impl<Fx, X> Rv<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Rv<X>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

impl<Fx, X> Support<X> for Fx where
    Fx: Deref,
    <Fx as Deref>::Target: Support<X>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,