This class represents the Gamma distribution. More...
Public Member Functions | |
GammaDistribution (const size_t dimensionality=0) | |
Construct the Gamma distribution with the given number of dimensions (default 0); each parameter will be initialized to 0. More... | |
GammaDistribution (const arma::mat &data, const double tol=1e-8) | |
Construct the Gamma distribution, training on the given parameters. More... | |
GammaDistribution (const arma::vec &alpha, const arma::vec &beta) | |
Construct the Gamma distribution given two vectors alpha and beta. More... | |
~GammaDistribution () | |
Destructor. More... | |
double | Alpha (const size_t dim) const |
Get the alpha parameter of the given dimension. More... | |
double & | Alpha (const size_t dim) |
Modify the alpha parameter of the given dimension. More... | |
double | Beta (const size_t dim) const |
Get the beta parameter of the given dimension. More... | |
double & | Beta (const size_t dim) |
Modify the beta parameter of the given dimension. More... | |
size_t | Dimensionality () const |
Get the dimensionality of the distribution. More... | |
void | LogProbability (const arma::mat &observations, arma::vec &logProbabilities) const |
This function returns the logarithm of the probability of a group of observations. More... | |
double | LogProbability (double x, const size_t dim) const |
This function returns the logarithm of the probability of a single observation. More... | |
void | Probability (const arma::mat &observations, arma::vec &probabilities) const |
This function returns the probability of a group of observations. More... | |
double | Probability (double x, const size_t dim) const |
This is a shortcut to the Probability(arma::mat&, arma::vec&) function for when we want to evaluate only the probability of one dimension of the gamma. More... | |
arma::vec | Random () const |
This function returns an observation of this distribution. More... | |
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. More... | |
void | Train (const arma::mat &observations, const arma::vec &probabilities, const double tol=1e-8) |
Fits an alpha and beta parameter according to observation probabilities. More... | |
void | Train (const arma::vec &logMeanxVec, const arma::vec &meanLogxVec, const arma::vec &meanxVec, const double tol=1e-8) |
This function trains (fits distribution parameters) to a dataset with pre-computed statistics logMeanx, meanLogx, meanx for each dimension. More... | |
This class represents the Gamma distribution.
It supports training a Gamma distribution on a given dataset and accessing the fitted alpha and beta parameters.
This class supports multidimensional Gamma distributions; however, it is assumed that each dimension is independent; therefore, a multidimensional Gamma distribution here may be seen as a set of independent single-dimensional Gamma distributions—and the parameters are estimated under this assumption.
The estimation algorithm used can be found in the following paper:
Definition at line 51 of file gamma_distribution.hpp.
GammaDistribution | ( | const size_t | dimensionality = 0 | ) |
Construct the Gamma distribution with the given number of dimensions (default 0); each parameter will be initialized to 0.
dimensionality | Number of dimensions. |
GammaDistribution | ( | const arma::mat & | data, |
const double | tol = 1e-8 |
||
) |
Construct the Gamma distribution, training on the given parameters.
data | Data to train the distribution on. |
tol | Convergence tolerance. This is not an absolute measure: It will stop the approximation once the change in the value is smaller than tol. |
GammaDistribution | ( | const arma::vec & | alpha, |
const arma::vec & | beta | ||
) |
Construct the Gamma distribution given two vectors alpha and beta.
alpha | The vector of alphas, one per dimension. |
beta | The vector of betas, one per dimension. |
|
inline |
Destructor.
Definition at line 83 of file gamma_distribution.hpp.
References GammaDistribution::LogProbability(), GammaDistribution::Probability(), GammaDistribution::Random(), and GammaDistribution::Train().
|
inline |
Get the alpha parameter of the given dimension.
Definition at line 196 of file gamma_distribution.hpp.
|
inline |
Modify the alpha parameter of the given dimension.
Definition at line 198 of file gamma_distribution.hpp.
|
inline |
Get the beta parameter of the given dimension.
Definition at line 201 of file gamma_distribution.hpp.
|
inline |
Modify the beta parameter of the given dimension.
Definition at line 203 of file gamma_distribution.hpp.
|
inline |
Get the dimensionality of the distribution.
Definition at line 206 of file gamma_distribution.hpp.
void LogProbability | ( | const arma::mat & | observations, |
arma::vec & | logProbabilities | ||
) | const |
This function returns the logarithm of the probability of a group of observations.
The logarithm of the probability of a value x is
for one dimension. This implementation assumes each dimension is independent, so the product rule is used.
observations | Matrix of observations, one per column. |
logProbabilities | Column vector of log probabilities, one per observation. |
Referenced by GammaDistribution::~GammaDistribution().
double LogProbability | ( | double | x, |
const size_t | dim | ||
) | const |
This function returns the logarithm of the probability of a single observation.
x | The 1-dimensional observation. |
dim | The dimension for which to calculate the probability. |
void Probability | ( | const arma::mat & | observations, |
arma::vec & | probabilities | ||
) | const |
This function returns the probability of a group of observations.
The probability of the value x is
for one dimension. This implementation assumes each dimension is independent, so the product rule is used.
observations | Matrix of observations, one per column. |
probabilities | Column vector of probabilities, one per observation. |
Referenced by GammaDistribution::~GammaDistribution().
double Probability | ( | double | x, |
const size_t | dim | ||
) | const |
This is a shortcut to the Probability(arma::mat&, arma::vec&) function for when we want to evaluate only the probability of one dimension of the gamma.
x | The 1-dimensional observation. |
dim | The dimension for which to calculate the probability. |
arma::vec Random | ( | ) | const |
This function returns an observation of this distribution.
Referenced by GammaDistribution::~GammaDistribution().
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.
rdata | Reference data to fit parameters to. |
tol | Convergence tolerance. This is not an absolute measure: It will stop the approximation once the change in the value is smaller than tol. |
Referenced by GammaDistribution::~GammaDistribution().
void Train | ( | const arma::mat & | observations, |
const arma::vec & | probabilities, | ||
const double | tol = 1e-8 |
||
) |
Fits an alpha and beta parameter according to observation probabilities.
This method is not yet implemented.
observations | The reference data, one observation per column. |
probabilities | The probability of each observation. One value per column of the observations matrix. |
tol | Convergence tolerance. This is not an absolute measure: It will stop the approximation once the change in the value is smaller than tol. |
void Train | ( | const arma::vec & | logMeanxVec, |
const arma::vec & | meanLogxVec, | ||
const arma::vec & | meanxVec, | ||
const double | tol = 1e-8 |
||
) |
This function trains (fits distribution parameters) to a dataset with pre-computed statistics logMeanx, meanLogx, meanx for each dimension.
logMeanxVec | Is each dimension's logarithm of the mean (log(mean(x))). |
meanLogxVec | Is each dimension's mean of logarithms (mean(log(x))). |
meanxVec | Is each dimension's mean (mean(x)). |
tol | Convergence tolerance. This is not an absolute measure: It will stop the approximation once the change in the value is smaller than tol. |