12 #ifndef MLPACK_CORE_DISTRIBUTIONS_DIAGONAL_GAUSSIAN_DISTRIBUTION_HPP 13 #define MLPACK_CORE_DISTRIBUTIONS_DIAGONAL_GAUSSIAN_DISTRIBUTION_HPP 18 namespace distribution {
34 static const constexpr
double log2pi = 1.83787706640934533908193770912475883;
47 mean(arma::zeros<arma::vec>(dimension)),
48 covariance(arma::ones<arma::vec>(dimension)),
49 invCov(arma::ones<arma::vec>(dimension)),
61 const arma::vec& covariance);
82 void Probability(
const arma::mat& x, arma::vec& probabilities)
const 84 arma::vec logProbabilities;
86 probabilities = arma::exp(logProbabilities);
97 arma::vec& logProbabilities)
const;
112 void Train(
const arma::mat& observations);
123 void Train(
const arma::mat& observations,
124 const arma::vec& probabilities);
127 const arma::vec&
Mean()
const {
return mean; }
130 arma::vec&
Mean() {
return mean; }
142 template<
typename Archive>
146 ar(CEREAL_NVP(mean));
147 ar(CEREAL_NVP(covariance));
148 ar(CEREAL_NVP(invCov));
149 ar(CEREAL_NVP(logDetCov));
arma::vec & Mean()
Return a modifiable copy of the mean.
Linear algebra utility functions, generally performed on matrices or vectors.
double Probability(const arma::vec &observation) const
Return the probability of the given observation.
The core includes that mlpack expects; standard C++ includes and Armadillo.
double LogProbability(const arma::vec &observation) const
Return the log probability of the given observation.
void Train(const arma::mat &observations)
Estimate the Gaussian distribution directly from the given observations.
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
void Probability(const arma::mat &x, arma::vec &probabilities) const
Calculate the multivariate Gaussian probability density function for each data point (column) in the ...
const arma::vec & Mean() const
Return the mean.
DiagonalGaussianDistribution()
Default constructor, which creates a Gaussian with zero dimension.
size_t Dimensionality() const
Return the dimensionality of this distribution.
void serialize(Archive &ar, const uint32_t)
Serialize the distribution.
DiagonalGaussianDistribution(const size_t dimension)
Create a Gaussian Distribution with zero mean and diagonal covariance with the given dimensionality...
const arma::vec & Covariance() const
Return the covariance matrix.
A single multivariate Gaussian distribution with diagonal covariance.