Yes, that is very true. retaining separate computations for each object (what currently happens) stops such headaches from occuring. Individual stats that work in this way are modular without major concern for "incremental" state. Approaching my example above does create and env where "incrementation" has to be tightly managed.Still, with a little invention I think this could be easily worked around. Especially with the functor model. Either with separate extensions of the increment method that could accept precalculated moments to use in the calculation, or constructors that wire in the moment being used by the UnivaraiateStatistic, thus reducing the replication.
*Constructor approach to reusing moments.*
Mean mean = new Mean();
SecondMoment m2 = new SecondMoment(mean);
ThirdMoment m3 = new ThirdMoment(mean, m2);
FourthMoment m4 = new FourthMoment(mean, m2, m3);
Variance var = new Variance(m2);
Skew skew = new Skew(variance, m3);
Kurt kurt = new Kurt(variance, m4);
*Incremental approach to reusing moments.* Mean mean = new Mean(); SecondMoment m2 = new SecondMoment(); ThirdMoment m3 = new ThirdMoment(); FourthMoment m4 = new FourthMoment(); Variance var = new Variance(); Skew skew = new Skew(); Kurt kurt = new Kurt();
mean.increment(d); m2.increment(d, m1); m3.increment(d, m1, m2); m4.increment(d, m1, m2, m3);
var.increment(d, m1); skew.increment(d, m2); kurt.increment(d, m4);
One problem with this approach, is now order of computation for each statistic object is a big concern. The responsibility of correct ordering would have to be placed in univariate with Mark's statistics objects. It would be better to place that responsibility in the statistic objects themselves
Hmm, can you elaborate a bit on this, I'm not quite sure I understand how a composite could be adapted into individual metrics while still working with the Statistic interface. Wouldn't you end up back atMaybe we could make composite statistic objects that can compute more than one metric. The composite would conform to the same statistic interface and would be adaptable into individual metrics. Also, the responsibility of computation ordering would be hidden in the composite, removed from univariate.
Brent Worden
http://www.brent.worden.org/
getMean() getVar() ...
to recover the separate stats in the composite? and still would'nt you need to calculate m2 - m4 even in the case that you just wanted to get the Mean?
-M.
-- Mark Diggory Software Developer Harvard MIT Data Center http://www.hmdc.harvard.edu
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
