You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Mark R. Diggory" <md...@latte.harvard.edu> on 2004/07/12 00:50:49 UTC

Re: [math] cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment Variance.java

Phil,

I wanted to point out there is a "test(...)" method in the
AbstractUnivariateStatistic class for validation of the input, this 
provides three test conditions for the incoming array and its 
starting/ending indicies. Most of the UnivariateStatistics reuse this 
for consistent validation. I'd recommend using it here:

> +    public double evaluate(final double[] values, final double mean) {
> +        if (values == null) { 
> +            throw new IllegalArgumentException("input values array  is null");
> +        } 
> +        return evaluate(values, mean, 0, values.length); 
> +    }

Heres a reference to it in the xref:

http://jakarta.apache.org/commons/math/xref/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.html#54

and an example where I've used it:

http://jakarta.apache.org/commons/math/xref/org/apache/commons/math/stat/univariate/rank/Percentile.html#121


-Mark

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

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


Re: [math] cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/moment Variance.java

Posted by Phil Steitz <ph...@steitz.com>.
Mark R. Diggory wrote:
> Phil,
> 
> I wanted to point out there is a "test(...)" method in the
> AbstractUnivariateStatistic class for validation of the input, this 
> provides three test conditions for the incoming array and its 
> starting/ending indicies. Most of the UnivariateStatistics reuse this 
> for consistent validation. I'd recommend using it here:
> 
>> +    public double evaluate(final double[] values, final double mean) {
>> +        if (values == null) { +            throw new 
>> IllegalArgumentException("input values array  is null");
>> +        } +        return evaluate(values, mean, 0, values.length); 
>> +    }

Actually, test() is being used under the covers by the last line.  The 
null check above is redundant and has been removed.  Good catch.

Phil
> 


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