[][src]Trait rstat::Distribution

pub trait Distribution: From<Self::Params> {
    type Support: Space;
    type Params;
    fn support(&self) -> Self::Support;
fn params(&self) -> Self::Params;
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Sample<Self>; fn into_support(self) -> Self::Support { ... }
fn into_params(self) -> Self::Params { ... }
fn cdf(&self, x: &Sample<Self>) -> Probability { ... }
fn ccdf(&self, x: &Sample<Self>) -> Probability { ... }
fn log_cdf(&self, x: &Sample<Self>) -> f64 { ... }
fn log_ccdf(&self, x: &Sample<Self>) -> f64 { ... }
fn sample_n<R: Rng + ?Sized>(
        &self,
        rng: &mut R,
        n: usize
    ) -> Vec<Sample<Self>> { ... }
fn sample_iter<'a, R: Rng + ?Sized>(
        &'a self,
        rng: &'a mut R
    ) -> Sampler<'a, Self, R> { ... } }

Trait for probability distributions with a well-defined CDF.

Associated Types

type Support: Space

Support of sample elements.

type Params

Parameter set uniquely defining the instance.

Loading content...

Required methods

fn support(&self) -> Self::Support

Returns an instance of the support Space, Self::Support.

Examples

let dist = univariate::beta::Beta::default();
let support = dist.support();

assert_eq!(support.dim(), Dim::Finite(1));
assert_eq!(support.inf().unwrap(), 0.0);
assert_eq!(support.sup().unwrap(), 1.0);

fn params(&self) -> Self::Params

Returns an instance of the distribution parameters, Self::Params.

Examples

let dist = univariate::normal::Normal::standard();
let params = dist.params();

assert_eq!(params.mu.value(), &0.0);
assert_eq!(params.Sigma.value(), &1.0);

fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> Sample<Self>

Draw a random value from the distribution support.

Loading content...

Provided methods

fn into_support(self) -> Self::Support

Converts self into an instance of Self::Support.

fn into_params(self) -> Self::Params

Converts self into an instance of Self::Params.

fn cdf(&self, x: &Sample<Self>) -> Probability

Evaluates the cumulative distribution function (CDF) at \(x\).

The CDF is defined as the probability that a random variable \(X\) takes on a value less than or equal to \(x\), i.e. \(F(x) = P(X \leq x)\).

Examples

let dist = univariate::normal::Normal::standard();

assert_eq!(dist.cdf(&f64::NEG_INFINITY), Probability::zero());
assert_eq!(dist.cdf(&0.0), Probability::half());
assert_eq!(dist.cdf(&f64::INFINITY), Probability::one());

fn ccdf(&self, x: &Sample<Self>) -> Probability

Evaluates the complementary CDF at \(x\).

The complementary CDF (also known as the survival function) is defined as the probability that a random variable \(X\) takes on a value strictly greater than \(x\), i.e. \(\bar{F}(x) = P(X > x) = 1 - F(x)\).

fn log_cdf(&self, x: &Sample<Self>) -> f64

Evaluates the log CDF at \(x\), i.e. \(\ln{F(x)}\).

fn log_ccdf(&self, x: &Sample<Self>) -> f64

Evaluates the log complementary CDF at \(x\), i.e. \(\ln{(1 - F(x))}\).

fn sample_n<R: Rng + ?Sized>(&self, rng: &mut R, n: usize) -> Vec<Sample<Self>>

Draw n random value from the distribution support.

fn sample_iter<'a, R: Rng + ?Sized>(
    &'a self,
    rng: &'a mut R
) -> Sampler<'a, Self, R>

Draw an indefinite number of random values from the distribution support.

Loading content...

Implementors

impl Distribution for Dirichlet[src]

impl Distribution for Multinomial[src]

type Support = ProductSpace<Ordinal>

type Params = Params

impl Distribution for BvNormal[src]

type Support = TwoSpace<Reals>

type Params = BvNormalParams

impl Distribution for MvNormal[src]

type Support = ProductSpace<Reals>

type Params = MvNormalParams

impl Distribution for PairedNormal[src]

impl Distribution for UvNormal[src]

type Support = Reals

type Params = UvNormalParams

impl Distribution for Arcsine[src]

type Support = Interval

type Params = Params

impl Distribution for Bernoulli[src]

type Support = Binary

type Params = Params

impl Distribution for Beta[src]

type Support = Interval

type Params = Params

impl Distribution for BetaBinomial[src]

type Support = Ordinal

type Params = Params

impl Distribution for BetaPrime[src]

type Support = PositiveReals

type Params = Params

impl Distribution for Binomial[src]

type Support = Ordinal

type Params = Params

impl Distribution for Categorical[src]

type Support = Ordinal

type Params = Params

impl Distribution for Cauchy[src]

type Support = Reals

type Params = Params

impl Distribution for Chi[src]

type Support = PositiveReals

type Params = Params

impl Distribution for ChiSq[src]

type Support = PositiveReals

type Params = Params

impl Distribution for Cosine[src]

type Support = Interval

type Params = Params

impl Distribution for Erlang[src]

type Support = PositiveReals

type Params = Params

impl Distribution for Exponential[src]

type Support = PositiveReals

type Params = Params

impl Distribution for FDist[src]

type Support = PositiveReals

type Params = Params

impl Distribution for FoldedNormal[src]

type Support = NonNegativeReals

type Params = Params

impl Distribution for Frechet[src]

type Support = Interval

type Params = Params

impl Distribution for Gamma[src]

type Support = PositiveReals

type Params = Params

impl Distribution for Geometric[src]

type Support = NonNegativeIntegers

type Params = Params

impl Distribution for GeneralisedExtremeValue[src]

type Support = Interval

type Params = Params

impl Distribution for GeneralisedPareto[src]

type Support = Interval

type Params = Params

impl Distribution for Gumbel[src]

type Support = Reals

type Params = Params

impl Distribution for InvGamma[src]

type Support = PositiveReals

type Params = Params

impl Distribution for InvNormal[src]

type Support = PositiveReals

type Params = Params

impl Distribution for Kumaraswamy[src]

type Support = Interval

type Params = Params

impl Distribution for Laplace[src]

type Support = Reals

type Params = Params

impl Distribution for Levy[src]

type Support = Interval

type Params = Params

impl Distribution for Logistic[src]

type Support = Reals

type Params = Params

impl Distribution for Pareto[src]

type Support = Interval

type Params = Params

impl Distribution for Poisson[src]

type Support = Naturals

type Params = Params

impl Distribution for Rayleigh[src]

type Support = PositiveReals

type Params = Params

impl Distribution for StudentT[src]

type Support = Reals

type Params = Params

impl Distribution for Triangular[src]

type Support = Interval

type Params = Params

impl Distribution for Uniform<f64>[src]

type Support = RealInterval

type Params = Params<f64>

impl Distribution for Uniform<i64>[src]

type Support = DiscreteInterval

type Params = Params<i64>

impl Distribution for Weibull[src]

type Support = PositiveReals

type Params = Params

impl Distribution for DiagonalNormal[src]

type Support = ProductSpace<Reals>

type Params = DiagonalNormalParams

impl Distribution for IsotropicNormal[src]

type Support = ProductSpace<Reals>

type Params = IsotropicNormalParams

impl<C: Distribution> Distribution for Mixture<C> where
    C::Support: Union + Clone
[src]

type Support = C::Support

type Params = Params<C::Params>

impl<S> Distribution for LogNormal<S> where
    Normal<Vector<f64>, S>: From<Params<S>> + Distribution<Support = ProductSpace<Reals>, Params = Params<S>>, 
[src]

type Support = ProductSpace<Reals>

type Params = Params<S>

Loading content...