[mlpack-git] [mlpack/mlpack] GammaDistribution: Adds functionality to solve #749 (#751)
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:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the mlpack-git