mlpack  1.0.12
gaussian_distribution.hpp
Go to the documentation of this file.
1 
14 #ifndef __MLPACK_METHODS_HMM_DISTRIBUTIONS_GAUSSIAN_DISTRIBUTION_HPP
15 #define __MLPACK_METHODS_HMM_DISTRIBUTIONS_GAUSSIAN_DISTRIBUTION_HPP
16 
17 #include <mlpack/core.hpp>
18 // Should be somewhere else, maybe in core.
20 
21 namespace mlpack {
22 namespace distribution {
23 
28 {
29  private:
31  arma::vec mean;
33  arma::mat covariance;
34 
35  public:
39  GaussianDistribution() { /* nothing to do */ }
40 
45  GaussianDistribution(const size_t dimension) :
46  mean(arma::zeros<arma::vec>(dimension)),
47  covariance(arma::eye<arma::mat>(dimension, dimension))
48  { /* Nothing to do. */ }
49 
53  GaussianDistribution(const arma::vec& mean, const arma::mat& covariance) :
54  mean(mean), covariance(covariance) { /* Nothing to do. */ }
55 
57  size_t Dimensionality() const { return mean.n_elem; }
58 
62  double Probability(const arma::vec& observation) const
63  {
64  return mlpack::gmm::phi(observation, mean, covariance);
65  }
66 
73  arma::vec Random() const;
74 
80  void Estimate(const arma::mat& observations);
81 
87  void Estimate(const arma::mat& observations,
88  const arma::vec& probabilities);
89 
91  const arma::vec& Mean() const { return mean; }
93  arma::vec& Mean() { return mean; }
94 
96  const arma::mat& Covariance() const { return covariance; }
98  arma::mat& Covariance() { return covariance; }
99 
103  std::string ToString() const;
104 };
105 
106 }; // namespace distribution
107 }; // namespace mlpack
108 
109 #endif
A single multivariate Gaussian distribution.
arma::vec mean
Mean of the distribution.
const arma::vec & Mean() const
Return the mean.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
arma::vec Random() const
Return a randomly generated observation according to the probability distribution defined by this obj...
void Estimate(const arma::mat &observations)
Estimate the Gaussian distribution directly from the given observations.
arma::mat & Covariance()
Return a modifiable copy of the covariance.
arma::mat covariance
Covariance of the distribution.
double phi(const double x, const double mean, const double var)
Calculates the univariate Gaussian probability density function.
Definition: phi.hpp:38
std::string ToString() const
Returns a string representation of this object.
double Probability(const arma::vec &observation) const
Return the probability of the given observation.
GaussianDistribution(const arma::vec &mean, const arma::mat &covariance)
Create a Gaussian distribution with the given mean and covariance.
size_t Dimensionality() const
Return the dimensionality of this distribution.
GaussianDistribution(const size_t dimension)
Create a Gaussian distribution with zero mean and identity covariance with the given dimensionality...
const arma::mat & Covariance() const
Return the covariance matrix.
GaussianDistribution()
Default constructor, which creates a Gaussian with zero dimension.
arma::vec & Mean()
Return a modifiable copy of the mean.