commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mark R. Diggory" <mdigg...@latte.harvard.edu>
Subject Re: [PROPOSAL] Commons-math
Date Sun, 11 May 2003 17:17:53 GMT
[+1] I'd have a very strong interest in becoming involved in such a 
project. I have a couple small tools I've build and I have and have a 
strong academic interest in this area.

1.) One of the downfalls I've experienced with Java Math packages in the 
past has to do with with scalability of statistical tools when doing 
simulations. I have a simple class, "Running Statistics" which provides 
means of "iterative calculation" of basic stats by retaining "sum of 
squares" and "count" information, which are then used to calculate 
things like "current Mean" and "current Variance". In "simulation" 
theres also the consideration in some cases of the "Window" over which 
such a calculation is made. I wouldn't be surprised if this also applied 
to things like web stats.

Having tools built on such a concept would be very powerful and very 
scalable. I've included an simplified example of this class, consider 
that this could also be applied to other stats such as "kurtosis".


2.) I'd think it would be interesting, as well, to consider how such a 
tool could relate to the development of a Java based "MathML" 
implementation. My first thought is the capability to build "DOM like" 
Object Oriented Math Equations which could be easily 
serialized/deserialized it to MathML? Also making such "Equations" 
functional and usable in a programmatic sense a well. Imagine, you could 
write a MathML equation, Deserialize into a java object, and plug it 
into a program to generate statistical output. In a "Dynamic modeling" 
sense, simulations could be written which actually create their own 
"Equations".

-Mark Diggory

<!-- Code snippet -->

/*
  * RunningBasicStatisticsTag.java
  *
  * Created on March 13, 2003, 10:19 PM
  */

package org.mrd.analysis;

/**
  * For each iteration of the model scan the list of agents, and
  * determine the following number of agents/number survived.
  *
  * keep calculated running average and std
  *
  * @author Mark Diggory <mdiggory@latte.harvard.edu>
  */
public class RunningBasicStatistics {

	protected double sum = 0;

	protected double sumsq = 0;

	protected double count = 0;

	/** Creates a new instance of RunningBasicStatisticsTag */
	public RunningBasicStatistics() {
	}

	public double getCurrentAverage() {
		return sum / count;
	}

	public double getCurrentVariance() {
		return (sumsq - (Math.pow(sum, 2) / count)) / count;
	}

	public double getCurrentStd() {
		return Math.sqrt(getCurrentVariance());
	}

	public void incriment(double value) {
		if (value != Double.NaN) {
			count++;
			sum = sum + value;
			sumsq = sumsq + Math.pow(value, 2);
		}
	}

	/**
	* @param args the command line arguments
	*/
	public static void main(String[] args) throws java.lang.Exception {

		RunningBasicStatistics probe = new RunningBasicStatistics();

		org.mrd.random.LimitedBeta beta =
			new org.mrd.random.LimitedBeta(
				.5,
				.5,
				new cern.jet.random.engine.MersenneTwister(),
				true,
				true);
		for (int i = 1; i < 10000; i++) {
			probe.incriment(beta.nextDouble());
		}

		System.out.println("Mean: " + probe.getCurrentAverage());
		System.out.println("Std: " + probe.getCurrentStd());
		System.out.println("Variance: " + probe.getCurrentVariance());
		System.out.println("");
	}
}

<!-- end code snippet -->


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message