gamma_distribution.hpp
Go to the documentation of this file.
1 
19 #ifndef _MLPACK_CORE_DISTRIBUTIONS_GAMMA_DISTRIBUTION_HPP
20 #define _MLPACK_CORE_DISTRIBUTIONS_GAMMA_DISTRIBUTION_HPP
21 
22 #include <mlpack/prereqs.hpp>
24 
25 namespace mlpack {
26 namespace distribution {
27 
52 {
53  public:
60  GammaDistribution(const size_t dimensionality = 0);
61 
70  GammaDistribution(const arma::mat& data, const double tol = 1e-8);
71 
78  GammaDistribution(const arma::vec& alpha, const arma::vec& beta);
79 
84 
94  void Train(const arma::mat& rdata, const double tol = 1e-8);
95 
107  void Train(const arma::mat& observations,
108  const arma::vec& probabilities,
109  const double tol = 1e-8);
110 
124  void Train(const arma::vec& logMeanxVec,
125  const arma::vec& meanLogxVec,
126  const arma::vec& meanxVec,
127  const double tol = 1e-8);
128 
145  void Probability(const arma::mat& observations,
146  arma::vec& probabilities) const;
147 
156  double Probability(double x, const size_t dim) const;
157 
176  void LogProbability(const arma::mat& observations,
177  arma::vec& logProbabilities) const;
178 
186  double LogProbability(double x, const size_t dim) const;
187 
191  arma::vec Random() const;
192 
193  // Access to Gamma distribution parameters.
194 
196  double Alpha(const size_t dim) const { return alpha[dim]; }
198  double& Alpha(const size_t dim) { return alpha[dim]; }
199 
201  double Beta(const size_t dim) const { return beta[dim]; }
203  double& Beta(const size_t dim) { return beta[dim]; }
204 
206  size_t Dimensionality() const { return alpha.n_elem; }
207 
208  private:
210  arma::vec alpha;
212  arma::vec beta;
213 
225  inline bool Converged(const double aOld,
226  const double aNew,
227  const double tol);
228 };
229 
230 } // namespace distribution
231 } // namespace mlpack
232 
233 #endif
arma::vec Random() const
This function returns an observation of this distribution.
Linear algebra utility functions, generally performed on matrices or vectors.
double & Alpha(const size_t dim)
Modify the alpha parameter of the given dimension.
The core includes that mlpack expects; standard C++ includes and Armadillo.
void LogProbability(const arma::mat &observations, arma::vec &logProbabilities) const
This function returns the logarithm of the probability of a group of observations.
double Alpha(const size_t dim) const
Get the alpha parameter of the given dimension.
void Train(const arma::mat &rdata, const double tol=1e-8)
This function trains (fits distribution parameters) to new data or the dataset the object owns...
size_t Dimensionality() const
Get the dimensionality of the distribution.
GammaDistribution(const size_t dimensionality=0)
Construct the Gamma distribution with the given number of dimensions (default 0); each parameter will...
double & Beta(const size_t dim)
Modify the beta parameter of the given dimension.
double Beta(const size_t dim) const
Get the beta parameter of the given dimension.
Miscellaneous math random-related routines.
void Probability(const arma::mat &observations, arma::vec &probabilities) const
This function returns the probability of a group of observations.
This class represents the Gamma distribution.