Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 40372 invoked from network); 18 Jun 2003 15:00:36 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 18 Jun 2003 15:00:36 -0000 Received: (qmail 19862 invoked by uid 97); 18 Jun 2003 15:02:56 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 19855 invoked from network); 18 Jun 2003 15:02:56 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 18 Jun 2003 15:02:56 -0000 Received: (qmail 40136 invoked by uid 500); 18 Jun 2003 15:00:33 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 40120 invoked from network); 18 Jun 2003 15:00:32 -0000 Received: from web41702.mail.yahoo.com (66.218.93.119) by daedalus.apache.org with SMTP; 18 Jun 2003 15:00:32 -0000 Message-ID: <20030618150034.10926.qmail@web41702.mail.yahoo.com> Received: from [12.10.219.28] by web41702.mail.yahoo.com via HTTP; Wed, 18 Jun 2003 08:00:34 PDT Date: Wed, 18 Jun 2003 08:00:34 -0700 (PDT) From: Phil Steitz Subject: Re: cvs commit: jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat StatUtils.java To: Jakarta Commons Developers List In-Reply-To: <20030618030128.54880.qmail@icarus.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N We need to get test cases committed for StatUtils before adding/modififying anything else. I am OK with what has been a added; but we need to comply with our stated guidelines, which require test cases for all committed code. StatUtils needs its own test cases. --- mdiggory@apache.org wrote: > mdiggory 2003/06/17 20:01:28 > > Modified: math/src/java/org/apache/commons/math/stat StatUtils.java > Log: > Adding corrected two-pass algorithm for variance calculation. > > Revision Changes Path > 1.5 +11 -2 > jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/StatUtils.java > > Index: StatUtils.java > =================================================================== > RCS file: > /home/cvs/jakarta-commons-sandbox/math/src/java/org/apache/commons/math/stat/StatUtils.java,v > retrieving revision 1.4 > retrieving revision 1.5 > diff -u -r1.4 -r1.5 > --- StatUtils.java 18 Jun 2003 01:56:03 -0000 1.4 > +++ StatUtils.java 18 Jun 2003 03:01:28 -0000 1.5 > @@ -155,7 +155,14 @@ > } > > /** > - * Returns the variance of the available values. > + * Returns the variance of the available values. This uses a corrected > + * two pass algorithm of the following > + * > + * corrected two pass formula (14.1.8), and also referenced > in:

> + * "Algorithms for Computing the Sample Variance: Analysis and > + * Recommendations", Chan, T.F., Golub, G.H., and LeVeque, R.J. > + * 1983, American Statistician, vol. 37, pp. 242?247. > + * > * @param values Is a double[] containing the values > * @return the result, Double.NaN if no values for an empty array > * or 0.0 for a single value set. > @@ -168,10 +175,12 @@ > } else if (values.length > 1) { > double mean = mean(values); > double accum = 0.0; > + double accum2 = 0.0; > for (int i = 0; i < values.length; i++) { > accum += Math.pow((values[i] - mean), 2.0); > + accum2 += (values[i] - mean); > } > - variance = accum / (double)(values.length - 1); > + variance = (accum - (Math.pow(accum2,2)/(double)values.length)) / > (double)(values.length - 1); > } > return variance; > } > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-dev-help@jakarta.apache.org > __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org