A discrete distribution where the only observations are discrete observations. More...
Public Member Functions | |
DiscreteDistribution () | |
Default constructor, which creates a distribution that has no observations. More... | |
DiscreteDistribution (const size_t numObservations) | |
Define the discrete distribution as having numObservations possible observations. More... | |
DiscreteDistribution (const arma::Col< size_t > &numObservations) | |
Define the multidimensional discrete distribution as having numObservations possible observations. More... | |
DiscreteDistribution (const std::vector< arma::vec > &probabilities) | |
Define the multidimensional discrete distribution as having the given probabilities for each observation. More... | |
size_t | Dimensionality () const |
Get the dimensionality of the distribution. More... | |
double | LogProbability (const arma::vec &observation) const |
Return the log probability of the given observation. More... | |
void | LogProbability (const arma::mat &x, arma::vec &logProbabilities) const |
Returns the Log probability of the given matrix. More... | |
arma::vec & | Probabilities (const size_t dim=0) |
Return the vector of probabilities for the given dimension. More... | |
const arma::vec & | Probabilities (const size_t dim=0) const |
Modify the vector of probabilities for the given dimension. More... | |
double | Probability (const arma::vec &observation) const |
Return the probability of the given observation. More... | |
void | Probability (const arma::mat &x, arma::vec &probabilities) const |
Calculates the Discrete probability density function for each data point (column) in the given matrix. More... | |
arma::vec | Random () const |
Return a randomly generated observation (one-dimensional vector; one observation) according to the probability distribution defined by this object. More... | |
template < typename Archive > | |
void | serialize (Archive &ar, const uint32_t) |
Serialize the distribution. More... | |
void | Train (const arma::mat &observations) |
Estimate the probability distribution directly from the given observations. More... | |
void | Train (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. More... | |
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.
Definition at line 45 of file discrete_distribution.hpp.
|
inline |
Default constructor, which creates a distribution that has no observations.
Definition at line 52 of file discrete_distribution.hpp.
|
inline |
Define the discrete distribution as having numObservations possible observations.
The probability in each state will be set to (1 / numObservations).
numObservations | Number of possible observations this distribution can have. |
Definition at line 63 of file discrete_distribution.hpp.
|
inline |
Define the multidimensional discrete distribution as having numObservations possible observations.
The probability in each state will be set to (1 / numObservations of each dimension).
numObservations | Number of possible observations this distribution can have. |
Definition at line 76 of file discrete_distribution.hpp.
|
inline |
Define the multidimensional discrete distribution as having the given probabilities for each observation.
probabilities | Probabilities of each possible observation. |
Definition at line 98 of file discrete_distribution.hpp.
|
inline |
Get the dimensionality of the distribution.
Definition at line 117 of file discrete_distribution.hpp.
|
inline |
Return the log 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.
observation | Observation to return the log probability of. |
Definition at line 166 of file discrete_distribution.hpp.
References DiscreteDistribution::Probability().
|
inline |
Returns the Log probability of the given matrix.
These values are stored in logProbabilities.
x | List of observations. |
logProbabilities | Output log-probabilities for each input observation. |
Definition at line 194 of file discrete_distribution.hpp.
References DiscreteDistribution::Probability(), DiscreteDistribution::Random(), and DiscreteDistribution::Train().
|
inline |
Return the vector of probabilities for the given dimension.
Definition at line 232 of file discrete_distribution.hpp.
|
inline |
Modify the vector of probabilities for the given dimension.
Definition at line 234 of file discrete_distribution.hpp.
|
inline |
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.
observation | Observation to return the probability of. |
Definition at line 127 of file discrete_distribution.hpp.
References Log::Fatal.
Referenced by DiscreteDistribution::LogProbability(), and DiscreteDistribution::Probability().
|
inline |
Calculates the Discrete probability density function for each data point (column) in the given matrix.
x | List of observations. |
probabilities | Output probabilities for each input observation. |
Definition at line 179 of file discrete_distribution.hpp.
References DiscreteDistribution::Probability().
arma::vec Random | ( | ) | const |
Return a randomly generated observation (one-dimensional vector; one observation) according to the probability distribution defined by this object.
Referenced by DiscreteDistribution::LogProbability(), MockCategoricalData(), and AggregatedPolicy< PolicyType >::Sample().
|
inline |
Serialize the distribution.
Definition at line 241 of file discrete_distribution.hpp.
void Train | ( | 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.
observations | List of observations. |
Referenced by DiscreteDistribution::LogProbability().
void Train | ( | 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.
observations | List of observations. |
probabilities | List of probabilities that each observation is actually from this distribution. |