Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 46562 invoked from network); 13 Apr 2010 14:07:15 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 13 Apr 2010 14:07:15 -0000 Received: (qmail 96252 invoked by uid 500); 13 Apr 2010 14:07:15 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 96176 invoked by uid 500); 13 Apr 2010 14:07:15 -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 96048 invoked by uid 99); 13 Apr 2010 14:07:15 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 14:07:15 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Apr 2010 14:07:12 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o3DE6ojx011568 for ; Tue, 13 Apr 2010 10:06:51 -0400 (EDT) Message-ID: <1864756.24541271167610747.JavaMail.jira@thor> Date: Tue, 13 Apr 2010 10:06:50 -0400 (EDT) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (MATH-364) Make Erf more precise in the tails by providing erfc In-Reply-To: <24067609.17721271146489879.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/MATH-364?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12856429#action_12856429 ] Phil Steitz commented on MATH-364: ---------------------------------- Thanks for the patch! This looks like a good enhancement. Two things would be helpful to get this incorporated into commons math. 1) You need to confirm that you can and are willing to contribute the code inline above under the terms of the Apache Contributor License Agreement (http://www.apache.org/licenses/icla.txt). You don't need to file this at this point, but you are certainly welcome to do so. Just a comment saying you agree to the terms for the code above is fine for now. 2) Unit tests, ideally using reference data. I will eventually do this if no one has time / itch to do it; but it will speed things up if someone adds them. It would be a little easier for us if the new code and unit tests were included in a patch file (see http://commons.apache.org/patches.html) Thanks again for your interest and contribution! > Make Erf more precise in the tails by providing erfc > ---------------------------------------------------- > > Key: MATH-364 > URL: https://issues.apache.org/jira/browse/MATH-364 > Project: Commons Math > Issue Type: Improvement > Affects Versions: 2.1 > Reporter: Christian Winter > Priority: Minor > > First I want to thank Phil Steitz for making Erf stable in the tails through adjusting the choices in calculating the regularized gamma functions, see [Math-282|https://issues.apache.org/jira/browse/MATH-282]. However, the precision of Erf in the tails is limitted to fixed point precision because of the closeness to +/-1.0, although the Gamma class could provide much more accuracy. Thus I propose to add the methods erfc(double) and erf(double, double) to the class Erf: > {code:borderStyle=solid} > /** > * Returns the complementary error function erfc(x). > * @param x the value > * @return the complementary error function erfc(x) > * @throws MathException if the algorithm fails to converge > */ > public static double erfc(double x) throws MathException { > double ret = Gamma.regularizedGammaQ(0.5, x * x, 1.0e-15, 10000); > if (x < 0) { > ret = -ret; > } > return ret; > } > /** > * Returns the difference of the error function values of x1 and x2. > * @param x1 the first bound > * @param x2 the second bound > * @return erf(x2) - erf(x1) > * @throws MathException > */ > public static double erf(double x1, double x2) throws MathException { > if(x1>x2) > return erf(x2, x1); > if(x1==x2) > return 0.0; > > double f1 = erf(x1); > double f2 = erf(x2); > > if(f2 > 0.5) > if(f1 > 0.5) > return erfc(x1) - erfc(x2); > else > return (0.5-erfc(x2)) + (0.5-f1); > else > if(f1 < -0.5) > if(f2 < -0.5) > return erfc(-x2) - erfc(-x1); > else > return (0.5-erfc(-x1)) + (0.5+f2); > else > return f2 - f1; > } > {code} > Further this can be used to improve the NormalDistributionImpl through > {code:borderStyle=solid} > @Override > public double cumulativeProbability(double x0, double x1) throws MathException { > return 0.5 * Erf.erf( > (x0 - getMean()) / (getStandardDeviation() * sqrt2), > (x1 - getMean()) / (getStandardDeviation() * sqrt2) ); > } > {code} -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira