[mlpack-git] [mlpack/mlpack] GammaDistribution: Adds functionality to solve #749 (#751)

Ryan Curtin notifications at github.com
Fri Aug 5 23:33:39 EDT 2016


> +  // Compute denominator only once for each dimension.
> +  arma::vec denominators(alpha.n_elem);
> +  for (size_t d = 0; d < alpha.n_elem; ++d)
> +    denominators(d) = std::tgamma(alpha(d)) * std::pow(beta(d), alpha(d));
> +
> +  // Compute probability of each observation.
> +  for (size_t i = 0; i < numObs; ++i)
> +  {
> +    for (size_t d = 0; d < observations.n_rows; ++d)
> +    {
> +      // Compute probability using Multiplication Law and Logarithm addition
> +      // property.
> +      LogProbabilities(i) += std::log( 
> +        std::pow(observations(d, i), alpha(d) - 1) 
> +        * std::exp(-observations(d, i) / beta(d)) 
> +        / denominators(d));

Same comment about indentation and readability applies here.

---
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/mlpack/mlpack/pull/751/files/9cb117f671f55186baddf38ce71107a2a3ae027f#r73780120
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160805/8d403b07/attachment.html>


More information about the mlpack-git mailing list