CPD

Trait CPD 

Source
pub trait CPD:
    Clone
    + Debug
    + Labelled
    + PartialEq
    + AbsDiffEq
    + RelativeEq {
    type Support;
    type Parameters;
    type Statistics;

    // Required methods
    fn conditioning_labels(&self) -> &Labels;
    fn parameters(&self) -> &Self::Parameters;
    fn parameters_size(&self) -> usize;
    fn sample_statistics(&self) -> Option<&Self::Statistics>;
    fn sample_log_likelihood(&self) -> Option<f64>;
    fn pf(&self, x: &Self::Support, z: &Self::Support) -> f64;
    fn sample<R: Rng>(&self, rng: &mut R, z: &Self::Support) -> Self::Support;
}
Expand description

A trait for conditional probability distributions.

Required Associated Types§

Source

type Support

The type of the support.

Source

type Parameters

The type of the parameters.

Source

type Statistics

The type of the sufficient statistics.

Required Methods§

Source

fn conditioning_labels(&self) -> &Labels

Returns the labels of the conditioned variables.

§Returns

A reference to the conditioning labels.

Source

fn parameters(&self) -> &Self::Parameters

Returns the parameters.

§Returns

A reference to the parameters.

Source

fn parameters_size(&self) -> usize

Returns the parameters size.

§Returns

The parameters size.

Source

fn sample_statistics(&self) -> Option<&Self::Statistics>

Returns the sufficient statistics, if any.

§Returns

An option containing a reference to the sufficient statistics.

Source

fn sample_log_likelihood(&self) -> Option<f64>

Returns the log-likelihood of the fitted dataset, if any.

§Returns

An option containing the log-likelihood.

Source

fn pf(&self, x: &Self::Support, z: &Self::Support) -> f64

Returns the value of probability (mass or density) function for P(X = x | Z = z).

§Arguments
  • x - The value of the conditioned variables.
  • z - The value of the conditioning variables.
§Returns

The probability P(X = x | Z = z).

Source

fn sample<R: Rng>(&self, rng: &mut R, z: &Self::Support) -> Self::Support

Samples from the conditional distribution P(X | Z = z).

§Arguments
  • rng - A mutable reference to a random number generator.
  • z - The value of the conditioning variables.
§Returns

A sample from P(X | Z = z).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§