MLPACK  1.0.11
gaussian_distribution.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_METHODS_HMM_DISTRIBUTIONS_GAUSSIAN_DISTRIBUTION_HPP
23 #define __MLPACK_METHODS_HMM_DISTRIBUTIONS_GAUSSIAN_DISTRIBUTION_HPP
24 
25 #include <mlpack/core.hpp>
26 // Should be somewhere else, maybe in core.
28 
29 namespace mlpack {
30 namespace distribution {
31 
36 {
37  private:
39  arma::vec mean;
41  arma::mat covariance;
42 
43  public:
47  GaussianDistribution() { /* nothing to do */ }
48 
53  GaussianDistribution(const size_t dimension) :
54  mean(arma::zeros<arma::vec>(dimension)),
55  covariance(arma::eye<arma::mat>(dimension, dimension))
56  { /* Nothing to do. */ }
57 
61  GaussianDistribution(const arma::vec& mean, const arma::mat& covariance) :
62  mean(mean), covariance(covariance) { /* Nothing to do. */ }
63 
65  size_t Dimensionality() const { return mean.n_elem; }
66 
70  double Probability(const arma::vec& observation) const
71  {
72  return mlpack::gmm::phi(observation, mean, covariance);
73  }
74 
81  arma::vec Random() const;
82 
88  void Estimate(const arma::mat& observations);
89 
95  void Estimate(const arma::mat& observations,
96  const arma::vec& probabilities);
97 
99  const arma::vec& Mean() const { return mean; }
101  arma::vec& Mean() { return mean; }
102 
104  const arma::mat& Covariance() const { return covariance; }
106  arma::mat& Covariance() { return covariance; }
107 
111  std::string ToString() const;
112 };
113 
114 }; // namespace distribution
115 }; // namespace mlpack
116 
117 #endif
A single multivariate Gaussian distribution.
arma::vec mean
Mean of the distribution.
const arma::vec & Mean() const
Return the mean.
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:46
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.