mlpack
master
|
A single multivariate Gaussian distribution. More...
Public Member Functions | |
GaussianDistribution () | |
Default constructor, which creates a Gaussian with zero dimension. More... | |
GaussianDistribution (const size_t dimension) | |
Create a Gaussian distribution with zero mean and identity covariance with the given dimensionality. More... | |
GaussianDistribution (const arma::vec &mean, const arma::mat &covariance) | |
Create a Gaussian distribution with the given mean and covariance. More... | |
const arma::mat & | Covariance () const |
Return the covariance matrix. More... | |
void | Covariance (const arma::mat &covariance) |
Set the covariance. More... | |
void | Covariance (arma::mat &&covariance) |
size_t | Dimensionality () const |
Return the dimensionality of this 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 |
Calculates the multivariate Gaussian log probability density function for each data point (column) in the given matrix. More... | |
const arma::vec & | Mean () const |
Return the mean. More... | |
arma::vec & | Mean () |
Return a modifiable copy of the mean. 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 multivariate Gaussian probability density function for each data point (column) in the given matrix. More... | |
arma::vec | Random () const |
Return a randomly generated observation according to the probability distribution defined by this object. More... | |
template<typename Archive > | |
void | Serialize (Archive &ar, const unsigned int) |
Serialize the distribution. More... | |
void | Train (const arma::mat &observations) |
Estimate the Gaussian distribution directly from the given observations. More... | |
void | Train (const arma::mat &observations, const arma::vec &probabilities) |
Estimate the Gaussian distribution from the given observations, taking into account the probability of each observation actually being from this distribution. More... | |
Private Member Functions | |
void | FactorCovariance () |
This factors the covariance using arma::chol(). More... | |
Private Attributes | |
arma::mat | covariance |
Positive definite covariance of the distribution. More... | |
arma::mat | covLower |
Lower triangular factor of cov (e.g. cov = LL^T). More... | |
arma::mat | invCov |
Cached inverse of covariance. More... | |
double | logDetCov |
Cached logdet(cov). More... | |
arma::vec | mean |
Mean of the distribution. More... | |
Static Private Attributes | |
static const constexpr double | log2pi = 1.83787706640934533908193770912475883 |
log(2pi) More... | |
A single multivariate Gaussian distribution.
Definition at line 24 of file gaussian_distribution.hpp.
|
inline |
Default constructor, which creates a Gaussian with zero dimension.
Definition at line 45 of file gaussian_distribution.hpp.
Referenced by GaussianDistribution().
|
inline |
Create a Gaussian distribution with zero mean and identity covariance with the given dimensionality.
Definition at line 51 of file gaussian_distribution.hpp.
References GaussianDistribution().
mlpack::distribution::GaussianDistribution::GaussianDistribution | ( | const arma::vec & | mean, |
const arma::mat & | covariance | ||
) |
Create a Gaussian distribution with the given mean and covariance.
covariance is expected to be positive definite.
|
inline |
Return the covariance matrix.
Definition at line 136 of file gaussian_distribution.hpp.
References covariance.
Referenced by mlpack::distribution::RegressionDistribution::RegressionDistribution().
void mlpack::distribution::GaussianDistribution::Covariance | ( | const arma::mat & | covariance | ) |
Set the covariance.
void mlpack::distribution::GaussianDistribution::Covariance | ( | arma::mat && | covariance | ) |
|
inline |
Return the dimensionality of this distribution.
Definition at line 69 of file gaussian_distribution.hpp.
|
private |
This factors the covariance using arma::chol().
The function assumes that the given matrix is factorizable via the Cholesky decomposition. If not, a std::runtime_error will be thrown.
Referenced by Serialize().
double mlpack::distribution::GaussianDistribution::LogProbability | ( | const arma::vec & | observation | ) | const |
Return the log probability of the given observation.
Referenced by Probability().
|
inline |
Calculates the multivariate Gaussian log probability density function for each data point (column) in the given matrix.
x | List of observations. |
probabilities | Output log probabilities for each input observation. |
Definition at line 177 of file gaussian_distribution.hpp.
|
inline |
|
inline |
Return a modifiable copy of the mean.
Definition at line 131 of file gaussian_distribution.hpp.
References mean.
|
inline |
Return the probability of the given observation.
Definition at line 74 of file gaussian_distribution.hpp.
References LogProbability().
|
inline |
Calculates the multivariate Gaussian 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 91 of file gaussian_distribution.hpp.
References LogProbability(), Random(), and Train().
arma::vec mlpack::distribution::GaussianDistribution::Random | ( | ) | const |
Return a randomly generated observation according to the probability distribution defined by this object.
Referenced by Probability().
|
inline |
Serialize the distribution.
Definition at line 149 of file gaussian_distribution.hpp.
References mlpack::data::CreateNVP(), and FactorCovariance().
void mlpack::distribution::GaussianDistribution::Train | ( | const arma::mat & | observations | ) |
Estimate the Gaussian distribution directly from the given observations.
observations | List of observations. |
Referenced by Probability().
void mlpack::distribution::GaussianDistribution::Train | ( | const arma::mat & | observations, |
const arma::vec & | probabilities | ||
) |
Estimate the Gaussian distribution from the given observations, taking into account the probability of each observation actually being from this distribution.
|
private |
Positive definite covariance of the distribution.
Definition at line 30 of file gaussian_distribution.hpp.
Referenced by Covariance().
|
private |
Lower triangular factor of cov (e.g. cov = LL^T).
Definition at line 32 of file gaussian_distribution.hpp.
|
private |
Cached inverse of covariance.
Definition at line 34 of file gaussian_distribution.hpp.
Referenced by LogProbability().
|
staticprivate |
|
private |
Cached logdet(cov).
Definition at line 36 of file gaussian_distribution.hpp.
Referenced by LogProbability().
|
private |
Mean of the distribution.
Definition at line 28 of file gaussian_distribution.hpp.
Referenced by LogProbability(), and Mean().