Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3A83A913C for ; Sat, 25 Feb 2012 20:20:14 +0000 (UTC) Received: (qmail 46138 invoked by uid 500); 25 Feb 2012 20:20:13 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 46020 invoked by uid 500); 25 Feb 2012 20:20:13 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 45827 invoked by uid 99); 25 Feb 2012 20:20:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Feb 2012 20:20:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED,T_RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.116] (HELO hel.zones.apache.org) (140.211.11.116) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 25 Feb 2012 20:20:10 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 7695933A859 for ; Sat, 25 Feb 2012 20:19:49 +0000 (UTC) Date: Sat, 25 Feb 2012 20:19:49 +0000 (UTC) From: =?utf-8?Q?S=C3=A9bastien_Brisard_=28Issue_Comment_Edited=29_=28JIRA=29?= To: issues@commons.apache.org Message-ID: <305381053.19998.1330201189487.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <847434589.16931.1330119604942.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Issue Comment Edited] (MATH-753) Better implementation for the gamma distribution density function MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-753?page=3Dcom.atlassian.j= ira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D132165= 29#comment-13216529 ]=20 S=C3=A9bastien Brisard edited comment on MATH-753 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 substit= ution only when it is necessary (for large values of alpha and beta). This = would require a little bit of investigation to find the appropriate thresho= lds. =20 was (Author: celestin): This suits me fine. The only concern I have is that using exp(log(x)) i= n place of x might incur a loss of accuracy. Maybe we should use this subst= itution only when it is necessary (for large values of alpha and beta). Thi= s would require a little bit of investigation to find the appropriate thres= holds. =20 > Better implementation for the gamma distribution density function > ----------------------------------------------------------------- > > Key: MATH-753 > URL: https://issues.apache.org/jira/browse/MATH-753 > 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 b= e 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 par= ameters alpha and beta.=20 > It would be sufficient to change the public double density(double x) func= tion at line 204 in the file org.apache.commons.math.distribution.GammaDist= ributionImpl as follows: > return Math.exp(Math.log( x )*(alpha-1) - Math.log(beta)*alpha - x/beta -= Gamma.logGamma(alpha));=20 > In order to improve performance, log(beta) and Gamma.logGamma(alpha) coul= d 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 administrato= rs: https://issues.apache.org/jira/secure/ContactAdministrators!default.jsp= a For more information on JIRA, see: http://www.atlassian.com/software/jira