int i;
int len;
int part;
int low = 0;
int high = inst.numInstances() - 1;
PairedStats full = new PairedStats(0.01);
PairedStats leftSubset = new PairedStats(0.01);
PairedStats rightSubset = new PairedStats(0.01);
int classIndex = inst.classIndex();
double leftCorr, rightCorr;
double leftVar, rightVar, allVar;
double order = 2.0;
initialize(low, high, attr);
if (m_number < 4) {
return;
}
len = ((high - low + 1) < 5) ? 1 : (high - low + 1) / 5;
m_position = low;
part = low + len - 1;
// prime the subsets
for (i = low; i < len; i++) {
full.add(inst.instance(i).value(attr),
inst.instance(i).value(classIndex));
leftSubset.add(inst.instance(i).value(attr),
inst.instance(i).value(classIndex));
}
for (i = len; i < inst.numInstances(); i++) {
full.add(inst.instance(i).value(attr),
inst.instance(i).value(classIndex));
rightSubset.add(inst.instance(i).value(attr),
inst.instance(i).value(classIndex));
}
full.calculateDerived();
allVar = (full.yStats.stdDev * full.yStats.stdDev);
allVar = Math.abs(allVar);
allVar = Math.pow(allVar, (1.0 / order));
for (i = low + len; i < high - len - 1; i++) {
rightSubset.subtract(inst.instance(i).value(attr),
inst.instance(i).value(classIndex));
leftSubset.add(inst.instance(i).value(attr),
inst.instance(i).value(classIndex));
if (!Utils.eq(inst.instance(i + 1).value(attr),
inst.instance(i).value(attr))) {
leftSubset.calculateDerived();
rightSubset.calculateDerived();
leftCorr = Math.abs(leftSubset.correlation);
rightCorr = Math.abs(rightSubset.correlation);
leftVar = (leftSubset.yStats.stdDev * leftSubset.yStats.stdDev);
leftVar = Math.abs(leftVar);