[][src]Trait statrs::distribution::CheckedContinuous

pub trait CheckedContinuous<T, K> {
    fn checked_pdf(&self, x: T) -> Result<K>;
fn checked_ln_pdf(&self, x: T) -> Result<K>; }

The CheckedContinuous trait provides an interface for interacting with continuous statistical distributions with possible failure modes

Required methods

fn checked_pdf(&self, x: T) -> Result<K>

Returns the probability density function calculated at x for a given distribution.

Examples

use statrs::distribution::{CheckedContinuous, Dirichlet};

let n = Dirichlet::new(&[1.0, 2.0, 3.0]).unwrap();
assert!(n.checked_pdf(&[0.0]).is_err());

fn checked_ln_pdf(&self, x: T) -> Result<K>

Returns the log of the probability density function calculated at x for a given distribution.

Examples

use statrs::distribution::{CheckedContinuous, Dirichlet};

let n = Dirichlet::new(&[1.0, 2.0, 3.0]).unwrap();
assert!(n.checked_ln_pdf(&[0.0]).is_err());
Loading content...

Implementors

impl<'a> CheckedContinuous<&'a [f64], f64> for Dirichlet[src]

fn checked_pdf(&self, x: &[f64]) -> Result<f64>[src]

Calculates the probabiliy density function for the dirichlet distribution with given x's corresponding to the concentration parameters for this distribution

Errors

If any element in x is not in (0, 1), the elements in x do not sum to 1 with a tolerance of 1e-4, or if x is not the same length as the vector of concentration parameters for this distribution

Formula

This example is not tested
(1 / B(α)) * Π(x_i^(α_i - 1))

where

This example is not tested
B(α) = Π(Γ(α_i)) / Γ(Σ(α_i))

α is the vector of concentration parameters, α_i is the ith concentration parameter, x_i is the ith argument corresponding to the ith concentration parameter, Γ is the gamma function, Π is the product from 1 to K, Σ is the sum from 1 to K, and K is the number of concentration parameters

fn checked_ln_pdf(&self, x: &[f64]) -> Result<f64>[src]

Calculates the log probabiliy density function for the dirichlet distribution with given x's corresponding to the concentration parameters for this distribution

Errors

If any element in x is not in (0, 1), the elements in x do not sum to 1 with a tolerance of 1e-4, or if x is not the same length as the vector of concentration parameters for this distribution

Formula

This example is not tested
ln((1 / B(α)) * Π(x_i^(α_i - 1)))

where

This example is not tested
B(α) = Π(Γ(α_i)) / Γ(Σ(α_i))

α is the vector of concentration parameters, α_i is the ith concentration parameter, x_i is the ith argument corresponding to the ith concentration parameter, Γ is the gamma function, Π is the product from 1 to K, Σ is the sum from 1 to K, and K is the number of concentration parameters

Loading content...