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 037F44EA7 for ; Wed, 15 Jun 2011 18:53:09 +0000 (UTC) Received: (qmail 2126 invoked by uid 500); 15 Jun 2011 18:53:09 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 2046 invoked by uid 500); 15 Jun 2011 18:53:09 -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 1979 invoked by uid 99); 15 Jun 2011 18:53:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jun 2011 18:53:09 +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; Wed, 15 Jun 2011 18:53:08 +0000 Received: from hel.zones.apache.org (hel.zones.apache.org [140.211.11.116]) by hel.zones.apache.org (Postfix) with ESMTP id EAB064192C4 for ; Wed, 15 Jun 2011 18:52:47 +0000 (UTC) Date: Wed, 15 Jun 2011 18:52:47 +0000 (UTC) From: "Phil Steitz (JIRA)" To: issues@commons.apache.org Message-ID: <2134240708.8108.1308163967957.JavaMail.tomcat@hel.zones.apache.org> In-Reply-To: <16041267.48771291219992137.JavaMail.jira@thor> Subject: [jira] [Commented] (MATH-449) Storeless covariance 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-449?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13049956#comment-13049956 ] Phil Steitz commented on MATH-449: ---------------------------------- I am leaning toward just adding a new class called StorelessCovariance and similar for StorelessPearsonsCorrelation that just provide bivariate statistics. You will notice that in fact the PersoansCorrelation class delegates to SimpleRegression which does the bivariate computation "storelessly" already. Thanks for adding the comment and for the contribution! > Storeless covariance > -------------------- > > Key: MATH-449 > URL: https://issues.apache.org/jira/browse/MATH-449 > Project: Commons Math > Issue Type: Improvement > Reporter: Patrick Meyer > Fix For: 3.0 > > Original Estimate: 168h > Remaining Estimate: 168h > > Currently there is no storeless version for computing the covariance. However, Pebay (2008) describes algorithms for on-line covariance computations, [http://infoserve.sandia.gov/sand_doc/2008/086212.pdf]. I have provided a simple class for implementing this algorithm. It would be nice to have this integrated into org.apache.commons.math.stat.correlation.Covariance. > {code} > //This code is granted for inclusion in the Apache Commons under the terms of the ASL. > public class StorelessCovariance{ > private double deltaX = 0.0; > private double deltaY = 0.0; > private double meanX = 0.0; > private double meanY = 0.0; > private double N=0; > private Double covarianceNumerator=0.0; > private boolean unbiased=true; > public Covariance(boolean unbiased){ > this.unbiased = unbiased; > } > public void increment(Double x, Double y){ > if(x!=null & y!=null){ > N++; > deltaX = x - meanX; > deltaY = y - meanY; > meanX += deltaX/N; > meanY += deltaY/N; > covarianceNumerator += ((N-1.0)/N)*deltaX*deltaY; > } > > } > public Double getResult(){ > if(unbiased){ > return covarianceNumerator/(N-1.0); > }else{ > return covarianceNumerator/N; > } > } > } > {code} -- This message is automatically generated by JIRA. For more information on JIRA, see: http://www.atlassian.com/software/jira