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 #include <boost/program_options.hpp>
25 
26 namespace mlpack {
27 namespace distribution {
28 
53 {
54  public:
61  GammaDistribution(const size_t dimensionality = 0);
62 
71  GammaDistribution(const arma::mat& data, const double tol = 1e-8);
72 
79  GammaDistribution(const arma::vec& alpha, const arma::vec& beta);
80 
85 
95  void Train(const arma::mat& rdata, const double tol = 1e-8);
96 
108  void Train(const arma::mat& observations,
109  const arma::vec& probabilities,
110  const double tol = 1e-8);
111 
125  void Train(const arma::vec& logMeanxVec,
126  const arma::vec& meanLogxVec,
127  const arma::vec& meanxVec,
128  const double tol = 1e-8);
129 
146  void Probability(const arma::mat& observations,
147  arma::vec& probabilities) const;
148 
157  double Probability(double x, const size_t dim) const;
158 
177  void LogProbability(const arma::mat& observations,
178  arma::vec& logProbabilities) const;
179 
187  double LogProbability(double x, const size_t dim) const;
188 
192  arma::vec Random() const;
193 
194  // Access to Gamma distribution parameters.
195 
197  double Alpha(const size_t dim) const { return alpha[dim]; }
199  double& Alpha(const size_t dim) { return alpha[dim]; }
200 
202  double Beta(const size_t dim) const { return beta[dim]; }
204  double& Beta(const size_t dim) { return beta[dim]; }
205 
207  size_t Dimensionality() const { return alpha.n_elem; }
208 
209  private:
211  arma::vec alpha;
213  arma::vec beta;
214 
226  inline bool Converged(const double aOld,
227  const double aNew,
228  const double tol);
229 };
230 
231 } // namespace distribution
232 } // namespace mlpack
233 
234 #endif
arma::vec Random() const
This function returns an observation of this distribution.
strip_type.hpp
Definition: add_to_po.hpp:21
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.