[ https://issues.apache.org/jira/browse/MATH753?page=com.atlassian.jira.plugin.system.issuetabpanels:commenttabpanel&focusedCommentId=13216529#comment13216529
]
Sébastien Brisard edited comment on MATH753 at 2/25/12 8:19 PM:

This suits me fine. The only concern I have is that using exp(log( x )) in place of x might
incur a loss of accuracy. Maybe we should use this substitution only when it is necessary
(for large values of alpha and beta). This would require a little bit of investigation to
find the appropriate thresholds.
was (Author: celestin):
This suits me fine. The only concern I have is that using exp(log(x)) in place of x might
incur a loss of accuracy. Maybe we should use this substitution only when it is necessary
(for large values of alpha and beta). This would require a little bit of investigation to
find the appropriate thresholds.
> Better implementation for the gamma distribution density function
> 
>
> Key: MATH753
> URL: https://issues.apache.org/jira/browse/MATH753
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: 2.2
> Reporter: Francesco Strino
> Priority: Minor
> Labels: improvement, stability
> Fix For: 2.2
>
>
> The way the density of the gamma distribution function is estimated can be improved.
> It's much more stable to calculate first the log of the density and then exponentiate,
otherwise the function returns NaN for high values of the parameters alpha and beta.
> It would be sufficient to change the public double density(double x) function at line
204 in the file org.apache.commons.math.distribution.GammaDistributionImpl as follows:
> return Math.exp(Math.log( x )*(alpha1)  Math.log(beta)*alpha  x/beta  Gamma.logGamma(alpha));
> In order to improve performance, log(beta) and Gamma.logGamma(alpha) could also be precomputed
and stored during initialization.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
