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 C3E8092BE for ; Fri, 24 Feb 2012 21:42:11 +0000 (UTC) Received: (qmail 57479 invoked by uid 500); 24 Feb 2012 21:42:10 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 57318 invoked by uid 500); 24 Feb 2012 21:42:10 -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 57251 invoked by uid 99); 24 Feb 2012 21:42:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 24 Feb 2012 21:42:10 +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; Fri, 24 Feb 2012 21:42:09 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id 9E8463395D4 for ; Fri, 24 Feb 2012 21:41:49 +0000 (UTC) Date: Fri, 24 Feb 2012 21:41:49 +0000 (UTC) From: "Francesco Strino (Updated) (JIRA)" To: issues@commons.apache.org Message-ID: <261420208.16951.1330119709650.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <847434589.16931.1330119604942.JavaMail.tomcat@hel.zones.apache.org> Subject: [jira] [Updated] (MATH-753) Better implementation for the gamma distribution density function MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/MATH-753?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Francesco Strino updated MATH-753: ---------------------------------- Description: 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 )*(alpha-1) - Math.log(beta)*alpha - x/beta - Gamma.logGamma(alpha)); was: 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)*(alpha-1) - Math.log(beta)*alpha - x/beta - Gamma.logGamma(alpha)); Summary: Better implementation for the gamma distribution density function (was: Better implementation for the gamma distribution implementation) > 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 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 )*(alpha-1) - Math.log(beta)*alpha - x/beta - Gamma.logGamma(alpha)); -- 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