commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Phil Steitz" <p...@steitz.com>
Subject Re: [math] exceptions or NaN from Univariate
Date Wed, 14 May 2003 04:52:17 GMT
O'brien, Tim wrote:
> Univariate getMean(), getVariance(), and getStandardDeviation() all
> contain a note to throw an exception if n = 0.  It should be noted that
> getVariance() and getStandardDeviation() don't make sense until n = 2.
> 
> The mean of an empty set is not a number, and currently calling (new
> Univariate("blah")).getMean() returns NaN.  I'm just wondering if
> throwing an exception is worth the trouble?  Any thoughts?
>  
> Tim
>  

A useful extension to Univariate would be to support a "rolling" 
capability, as follows:

Add a property called something like "windowSize" and change the 
contract to mean that getMean(), getVariance, etc. always return 
statistics on values {n, n-1, ... n-windowSize+1}.  Have the default 
windowSize "infinity" (i.e., no restriction).  This would be useful in 
applications (e.g simulation monitors) that need to compute "rolling 
averages".

Obviously, we would want to do this without storing all of the values 
{n, n-1, ... n-windowSize+1}.

Phil

> 
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message