SYNOPSIS

Public Member Functions

DiscreteDistribution ()

Default constructor, which creates a distribution that has no observations. DiscreteDistribution (const size_t numObservations)

Define the discrete distribution as having numObservations possible observations. DiscreteDistribution (const arma::vec &probabilities)

Define the discrete distribution as having the given probabilities for each observation. size_t Dimensionality () const

Get the dimensionality of the distribution. void Estimate (const arma::mat &observations)

Estimate the probability distribution directly from the given observations. void Estimate (const arma::mat &observations, const arma::vec &probabilities)

Estimate the probability distribution from the given observations, taking into account the probability of each observation actually being from this distribution. const arma::vec & Probabilities () const

Return the vector of probabilities. arma::vec & Probabilities ()

Modify the vector of probabilities. double Probability (const arma::vec &observation) const

Return the probability of the given observation. arma::vec Random () const

Return a randomly generated observation (one-dimensional vector; one observation) according to the probability distribution defined by this object. std::string ToString () const

Private Attributes

arma::vec probabilities

Detailed Description

A discrete distribution where the only observations are discrete observations.

This is useful (for example) with discrete Hidden Markov Models, where observations are non-negative integers representing specific emissions.

No bounds checking is performed for observations, so if an invalid observation is passed (i.e. observation > numObservations), a crash will probably occur.

This distribution only supports one-dimensional observations, so when passing an arma::vec as an observation, it should only have one dimension (vec.n_rows == 1). Any additional dimensions will simply be ignored.

Note:

This class, like every other class in MLPACK, uses arma::vec to represent observations. While a discrete distribution only has positive integers (size_t) as observations, these can be converted to doubles (which is what arma::vec holds). This distribution internally converts those doubles back into size_t before comparisons.

Definition at line 53 of file discrete_distribution.hpp.

Constructor & Destructor Documentation

mlpack::distribution::DiscreteDistribution::DiscreteDistribution ()\fC [inline]\fP

Default constructor, which creates a distribution that has no observations.

Definition at line 59 of file discrete_distribution.hpp.

mlpack::distribution::DiscreteDistribution::DiscreteDistribution (const size_tnumObservations)\fC [inline]\fP

Define the discrete distribution as having numObservations possible observations. The probability in each state will be set to (1 / numObservations).

Parameters:

numObservations Number of possible observations this distribution can have.

Definition at line 69 of file discrete_distribution.hpp.

mlpack::distribution::DiscreteDistribution::DiscreteDistribution (const arma::vec &probabilities)\fC [inline]\fP

Define the discrete distribution as having the given probabilities for each observation.

Parameters:

probabilities Probabilities of each possible observation.

Definition at line 79 of file discrete_distribution.hpp.

Member Function Documentation

size_t mlpack::distribution::DiscreteDistribution::Dimensionality () const\fC [inline]\fP

Get the dimensionality of the distribution.

Definition at line 95 of file discrete_distribution.hpp.

void mlpack::distribution::DiscreteDistribution::Estimate (const arma::mat &observations)

Estimate the probability distribution directly from the given observations. If any of the observations is greater than numObservations, a crash is likely to occur.

Parameters:

observations List of observations.

void mlpack::distribution::DiscreteDistribution::Estimate (const arma::mat &observations, const arma::vec &probabilities)

Estimate the probability distribution from the given observations, taking into account the probability of each observation actually being from this distribution.

Parameters:

observations List of observations.

probabilities List of probabilities that each observation is actually from this distribution.

const arma::vec& mlpack::distribution::DiscreteDistribution::Probabilities () const\fC [inline]\fP

Return the vector of probabilities.

Definition at line 153 of file discrete_distribution.hpp.

References probabilities.

arma::vec& mlpack::distribution::DiscreteDistribution::Probabilities ()\fC [inline]\fP

Modify the vector of probabilities.

Definition at line 155 of file discrete_distribution.hpp.

References probabilities.

double mlpack::distribution::DiscreteDistribution::Probability (const arma::vec &observation) const\fC [inline]\fP

Return the probability of the given observation. If the observation is greater than the number of possible observations, then a crash will probably occur -- bounds checking is not performed.

Parameters:

observation Observation to return the probability of.

Returns:

Probability of the given observation.

Definition at line 105 of file discrete_distribution.hpp.

References mlpack::Log::Debug, and probabilities.

arma::vec mlpack::distribution::DiscreteDistribution::Random () const

Return a randomly generated observation (one-dimensional vector; one observation) according to the probability distribution defined by this object.

Returns:

Random observation.

std::string mlpack::distribution::DiscreteDistribution::ToString () const

Member Data Documentation

arma::vec mlpack::distribution::DiscreteDistribution::probabilities\fC [private]\fP

Definition at line 163 of file discrete_distribution.hpp.

Referenced by Probabilities(), and Probability().

Author

Generated automatically by Doxygen for MLPACK from the source code.