SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.descriptive
Class SynchronizedStatistic

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.descriptive.SynchronizedStatistic
All Implemented Interfaces:
Statistic

public class SynchronizedStatistic
extends java.lang.Object
implements Statistic

This provides a thread-safe version of Statistic by synchronizing all public methods so that only one thread at a time can access the instance.

This is essentially the same principle used by Java's synchronized collection class.

See Also:
"Chapter 5. Java Concurrency in Practice. Brian Goetz, Tim Peierls, Joshua Bloch and Joseph Bowbeer."

Method Summary
 void addData(double... data)
          Recompute the statistic, incrementally if possible.
 long N()
          Get the size of the sample.
 double value()
          Get the value of the statistic.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addData

public void addData(double... data)
Description copied from interface: Statistic
Recompute the statistic, incrementally if possible.

Specified by:
addData in interface Statistic
Parameters:
data - an array of new items

value

public double value()
Description copied from interface: Statistic
Get the value of the statistic.

Specified by:
value in interface Statistic
Returns:
the statistic

N

public long N()
Description copied from interface: Statistic
Get the size of the sample.

Specified by:
N in interface Statistic
Returns:
the sample size

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.