Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 1118 invoked from network); 15 May 2003 23:30:06 -0000 Received: from exchange.sun.com (192.18.33.10) by daedalus.apache.org with SMTP; 15 May 2003 23:30:06 -0000 Received: (qmail 17382 invoked by uid 97); 15 May 2003 23:32:19 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 17375 invoked from network); 15 May 2003 23:32:19 -0000 Received: from daedalus.apache.org (HELO apache.org) (208.185.179.12) by nagoya.betaversion.org with SMTP; 15 May 2003 23:32:19 -0000 Received: (qmail 769 invoked by uid 500); 15 May 2003 23:30:01 -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 729 invoked from network); 15 May 2003 23:30:00 -0000 Received: from latte.harvard.edu (140.247.210.252) by daedalus.apache.org with SMTP; 15 May 2003 23:30:00 -0000 Received: from latte.harvard.edu (lorien.fas.harvard.edu [::ffff:140.247.212.206]) (IDENT: bgates, AUTH: LOGIN mdiggory) by latte.harvard.edu with esmtp; Thu, 15 May 2003 19:30:14 -0400 Message-ID: <3EC42373.3000507@latte.harvard.edu> Date: Thu, 15 May 2003 19:32:03 -0400 From: "Mark R. Diggory" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3) Gecko/20030312 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jakarta Commons Developers List Subject: Re: [math][patch] New RollingUnivariateImpl References: <3EC422D7.80307@latte.harvard.edu> In-Reply-To: <3EC422D7.80307@latte.harvard.edu> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N Ughh, sorry about the copyright that got dumped in there, feel free to replace it with the Apaches. Mark R. Diggory wrote: > Well the latest changes to the cvs made the implementation of the > RollingUnivariate quite simple indeed. Tell me what you think. > > -Mark > >------------------------------------------------------------------------ > >Index: .classpath >=================================================================== >RCS file: .classpath >diff -N .classpath >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .classpath 15 May 2003 23:22:10 -0000 >@@ -0,0 +1,6 @@ >+ >+ >+ >+ >+ >+ >Index: .project >=================================================================== >RCS file: .project >diff -N .project >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ .project 15 May 2003 23:22:10 -0000 >@@ -0,0 +1,17 @@ >+ >+ >+ math >+ >+ >+ >+ >+ >+ org.eclipse.jdt.core.javabuilder >+ >+ >+ >+ >+ >+ org.eclipse.jdt.core.javanature >+ >+ >Index: src/java/org/apache/commons/math/RollingUnivariate.java >=================================================================== >RCS file: src/java/org/apache/commons/math/RollingUnivariate.java >diff -N src/java/org/apache/commons/math/RollingUnivariate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/java/org/apache/commons/math/RollingUnivariate.java 15 May 2003 23:22:10 -0000 >@@ -0,0 +1,43 @@ >+package org.apache.commons.math; >+import org.apache.commons.math.StoreUnivariate; >+ >+/* >+ * Created on May 15, 2003 >+ * >+ * Copyright (C) 2002-2003, Mark Diggory >+ * >+ * This program is free software; you can redistribute it and/or modify >+ * it under the terms of the GNU General Public License as published by >+ * the Free Software Foundation; either version 2 of the License, or >+ * (at your option) any later version. >+ * >+ * This program is distributed in the hope that it will be useful, >+ * but WITHOUT ANY WARRANTY; without even the implied warranty of >+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ * GNU General Public License for more details. >+ * >+ * You should have received a copy of the GNU General Public License >+ * along with this program; if not, write to the Free Software >+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. License >+ * information is also available at http://www.gnu.org. >+ * >+ */ >+ >+/** >+ * @author administrator >+ * >+ * To change the template for this generated type comment go to >+ * Window>Preferences>Java>Code Generation>Code and Comments >+ */ >+public interface RollingUnivariate extends StoreUnivariate { >+ >+ /** >+ * @return >+ */ >+ public int getWindow(); >+ >+ /** >+ * @param i >+ */ >+ public void setWindow(int window); >+} >Index: src/java/org/apache/commons/math/RollingUnivariateImpl.java >=================================================================== >RCS file: src/java/org/apache/commons/math/RollingUnivariateImpl.java >diff -N src/java/org/apache/commons/math/RollingUnivariateImpl.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/java/org/apache/commons/math/RollingUnivariateImpl.java 15 May 2003 23:22:10 -0000 >@@ -0,0 +1,140 @@ >+/* ==================================================================== >+ * The Apache Software License, Version 1.1 >+ * >+ * Copyright (c) 2003 The Apache Software Foundation. All rights >+ * reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions >+ * are met: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * >+ * 2. Redistributions in binary form must reproduce the above copyright >+ * notice, this list of conditions and the following disclaimer in >+ * the documentation and/or other materials provided with the >+ * distribution. >+ * >+ * 3. The end-user documentation included with the redistribution, if >+ * any, must include the following acknowlegement: >+ * "This product includes software developed by the >+ * Apache Software Foundation (http://www.apache.org/)." >+ * Alternately, this acknowlegement may appear in the software itself, >+ * if and wherever such third-party acknowlegements normally appear. >+ * >+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software >+ * Foundation" must not be used to endorse or promote products derived >+ * from this software without prior written permission. For written >+ * permission, please contact apache@apache.org. >+ * >+ * 5. Products derived from this software may not be called "Apache" >+ * nor may "Apache" appear in their names without prior written >+ * permission of the Apache Software Foundation. >+ * >+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED >+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES >+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE >+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR >+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF >+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND >+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, >+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT >+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF >+ * SUCH DAMAGE. >+ * ==================================================================== >+ * >+ * This software consists of voluntary contributions made by many >+ * individuals on behalf of the Apache Software Foundation. For more >+ * information on the Apache Software Foundation, please see >+ * . >+ */ >+package org.apache.commons.math; >+ >+/** >+ * >+ * Accumulates univariate statistics for values fed in >+ * through the addValue() method. Stores only the data >+ * over the designated window of interest. >+ * >+ * @author Phil Steitz >+ * @author Mark Diggory >+ * @version >+ * >+*/ >+public class RollingUnivariateImpl extends AbstractStoreUnivariate implements RollingUnivariate{ >+ >+ /** Array of values for rolling */ >+ private double[] values = null; >+ >+ /** Array of values for rolling */ >+ private int index = 0; >+ >+ /** Window on which to calculate */ >+ private int window = 2; >+ >+ /** Creates new univariate */ >+ public RollingUnivariateImpl(int window){ >+ if(window < 2) throw new java.lang.IndexOutOfBoundsException("window must be greater than 2"); >+ values = new double[window]; >+ } >+ >+ >+ /* (non-Javadoc) >+ * @see org.apache.commons.math.StoreUnivariate#getValues() >+ */ >+ public double[] getValues() { >+ double[] copiedArray = new double[window]; >+ System.arraycopy( values, 0, copiedArray, 0, copiedArray.length); >+ return copiedArray; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.apache.commons.math.StoreUnivariate#getElement(int) >+ */ >+ public double getElement(int index) { >+ return values[index]; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.apache.commons.math.Univariate#getN() >+ */ >+ public double getN() { >+ return values.length; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.apache.commons.math.Univariate#addValue(double) >+ */ >+ public void addValue(double v) { >+ values[index] = v; >+ index = (index + 1) % values.length; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.apache.commons.math.Univariate#clear() >+ */ >+ public void clear() { >+ values = new double[window]; >+ this.index = 0; >+ } >+ >+ /** >+ * @return >+ */ >+ public int getWindow() { >+ return window; >+ } >+ >+ /** >+ * @param i >+ */ >+ public void setWindow(int window){ >+ if(window < 2) throw new java.lang.IndexOutOfBoundsException("window must be greater than 2"); >+ this.window = window; >+ clear(); >+ } >+ >+} > > > >------------------------------------------------------------------------ > >--------------------------------------------------------------------- >To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org >For additional commands, e-mail: commons-dev-help@jakarta.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org