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: [math] API changes for RC2
Date Mon, 27 Sep 2004 16:12:05 GMT


Al Chou wrote:
> 
> So someone please lay out a real(istic) use case.  Would you ever make two
> successive (or closely separated, anyway) method calls to get both the sample
> and population result for the same dataset?  Or do you usually just use one and
> not the other?  In pseudo-code, do you ever need to do this:
> 
> StandardDeviation sd = new StandardDeviation( ... ) ;
> sd.getResult() ;
> sd.getPopulationResult() ;
> 
> or is it sufficient functionality if you have to say something like:
> 
> 
> StandardDeviation sd = new StandardDeviation( ... ) ;
> sd.Result() ;
> sd.populationResult = true ;
> sd.Result() ;
> 
> I realize that it's only one extra line of code, but if you're calling these
> statistics often, one extra line per invocation could be enough to make the API
> unnecessarily awkward.
> 
> 
> Al

Al,

I address this in my other response. The real issue is that in the 
storeless case, any of these approaches is not possible because the 
statistic up to that point has been calculated using the earlier 
approach. You can't go back and recalculate it. The more logical 
approach is this:

StandardDeviation pop = new StandardDeviation(population_flag) ;
StandardDeviation sample = new StandardDeviation(sample_flag) ;

... add a bunch of values to both

double p = pop.getResult();
double s = sample.getResult();

Not only that, in this example its very clear which "Object" your 
working with, The statistics still stay separate Objects and the 
Variation in behavior is still encapsulated in the one implementation of 
StandardDeviation.

-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


Mime
View raw message