public Instance calcPivot(MyIdxList list1,MyIdxList list2,Instances insts){
  int classIdx=m_Instances.classIndex();
  double[] attrVals=new double[insts.numAttributes()];
  Instance temp;
  for (int i=0; i < list1.length(); i++) {
    temp=insts.instance(list1.get(i).idx);
    for (int k=0; k < temp.numValues(); k++) {
      if (temp.index(k) == classIdx) {
        continue;
      }
      attrVals[k]+=temp.valueSparse(k);
    }
  }
  for (int j=0; j < list2.length(); j++) {
    temp=insts.instance(list2.get(j).idx);
    for (int k=0; k < temp.numValues(); k++) {
      if (temp.index(k) == classIdx) {
        continue;
      }
      attrVals[k]+=temp.valueSparse(k);
    }
  }
  for (int j=0, numInsts=list1.length() + list2.length(); j < attrVals.length; j++) {
    attrVals[j]/=numInsts;
  }
  temp=new DenseInstance(1.0,attrVals);
  return temp;
}

public Instance calcPivot ( MyIdxList list1 , MyIdxList list2 , Instances insts ) { int classIdx = m_Instances . classIndex ( ) ; double [ ] attrVals = new double [ insts . numAttributes ( ) ] ; Instance temp ; for ( int i = 0 ; i < list1 . length ( ) ; i ++ ) { temp = insts . instance ( list1 . get ( i ) . idx ) ; for ( int k = 0 ; k < temp . numValues ( ) ; k ++ ) { if ( temp . index ( k ) == classIdx ) { continue ; } attrVals [ k ] += temp . valueSparse ( k ) ; } } for ( int j = 0 ; j < list2 . length ( ) ; j ++ ) { temp = insts . instance ( list2 . get ( j ) . idx ) ; for ( int k = 0 ; k < temp . numValues ( ) ; k ++ ) { if ( temp . index ( k ) == classIdx ) { continue ; } attrVals [ k ] += temp . valueSparse ( k ) ; } } for ( int j = 0 , numInsts = list1 . length ( ) + list2 . length ( ) ; j < attrVals . length ; j ++ ) { attrVals [ j ] /= numInsts ; } temp = new DenseInstance ( 1.0 , attrVals ) ; return temp ; }
calculates the centroid pivot of a node based on the list of points that it contains ( tbe two lists of its children are provided ) .
