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

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


> +      // Compute probability using Multiplication Law.
> +      probabilities(i) *= 
> +        std::pow(observations(d, i), alpha(d) - 1) *
> +        std::exp(-observations(d, i) / beta(d)) /
> +        denominators(d);
> +    }
> +  }
> +}
> +
> +// Returns the probability of one observation (x) for one of the Gamma's
> +// dimensions.
> +double GammaDistribution::Probability(double x, size_t dim) const
> +{
> +  return 
> +    std::pow(x, alpha(dim) - 1) * std::exp(-x / beta(dim)) / 
> +    (std::tgamma(alpha(dim)) * std::pow(beta(dim), alpha(dim)));

I know I'm being picky but I think the indentation needs to be one more here.  Another option is to split this into multiple lines for readability, but that's up to you.  Realistically, to the compiler, it shouldn't make a difference if you compute a bunch of doubles then multiply them together, or compute the result all at once.

---
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#r73780117
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160805/cd522a23/attachment-0001.html>


More information about the mlpack-git mailing list