I've written a (trivial) aggregator for mean, and another for variance:
"Aggregates the arithmetic mean of its input."
( [0 0])
([[sum count] val] [(+ sum val) (inc count)])
([[sum count]] [(float (/ sum count))])
"Aggregates the variance of its input."
( [0 0 0])
([[sumsq sum count] val] [(+ sumsq (* val val)) (+ sum val) (inc count)])
([[sumsq sum count]] (let [mean (float (/ sum count))] [(- (float (/
sumsq count)) (* mean mean))]))
I'd like to do two things:
1) combine them into one aggregator that returns both (and thus
accumulates sum and count once only);
2) implement them with a combiner.
I've seen the definition of sum (each sum-parallel), where sum-parallel is
but I don't see how that applies here, since defparallelop doesn't allow
and I don't see any other way to use a combiner. Are one or both of these
Many thanks (still learning!),