}
int dfwg = 0;
double sswg = 0;
Sum totsum = new Sum();
SumOfSquares totsumsq = new SumOfSquares();
int totnum = 0;
for (Iterator iterator = categoryData.iterator(); iterator.hasNext();) {
double[] data = (double[])iterator.next();
Sum sum = new Sum();
SumOfSquares sumsq = new SumOfSquares();
int num = 0;
for (int i = 0; i < data.length; i++) {
double val = data[i];
// within category
num++;
sum.increment(val);
sumsq.increment(val);
// for all categories
totnum++;
totsum.increment(val);
totsumsq.increment(val);
}
dfwg += num - 1;
double ss = sumsq.getResult() - sum.getResult() * sum.getResult() / num;
sswg += ss;
}
double sst = totsumsq.getResult() - totsum.getResult() *
totsum.getResult()/totnum;
double ssbg = sst - sswg;