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>
26 
27 namespace mlpack {
28 namespace distribution {
29 
54 {
55  public:
62  GammaDistribution(const size_t dimensionality = 0);
63 
72  GammaDistribution(const arma::mat& data, const double tol = 1e-8);
73 
80  GammaDistribution(const arma::vec& alpha, const arma::vec& beta);
81 
86 
96  void Train(const arma::mat& rdata, const double tol = 1e-8);
97 
109  void Train(const arma::mat& observations,
110  const arma::vec& probabilities,
111  const double tol = 1e-8);
112 
126  void Train(const arma::vec& logMeanxVec,
127  const arma::vec& meanLogxVec,
128  const arma::vec& meanxVec,
129  const double tol = 1e-8);
130 
147  void Probability(const arma::mat& observations,
148  arma::vec& probabilities) const;
149 
158  double Probability(double x, const size_t dim) const;
159 
178  void LogProbability(const arma::mat& observations,
179  arma::vec& logProbabilities) const;
180 
188  double LogProbability(double x, const size_t dim) const;
189 
193  arma::vec Random() const;
194 
195  // Access to Gamma distribution parameters.
196 
198  double Alpha(const size_t dim) const { return alpha[dim]; }
200  double& Alpha(const size_t dim) { return alpha[dim]; }
201 
203  double Beta(const size_t dim) const { return beta[dim]; }
205  double& Beta(const size_t dim) { return beta[dim]; }
206 
208  size_t Dimensionality() const { return alpha.n_elem; }
209 
210  private:
212  arma::vec alpha;
214  arma::vec beta;
215 
227  inline bool Converged(const double aOld,
228  const double aNew,
229  const double tol);
230 };
231 
232 } // namespace distribution
233 } // namespace mlpack
234 
235 #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.
constexpr auto data(Container const &container) noexcept -> decltype(container.data())
Definition: iterator.hpp:79
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.