private void calculateEntropy(double scale,KStarWrapper params){
  int i, j, k;
  double actent=0.0, randent=0.0;
  double pstar, tprob, avgprob=0.0, minprob=1.0;
  double actClassProb, randClassProb;
  double[][] pseudoClassProbs=new double[NUM_RAND_COLS + 1][m_NumClasses];
  for (j=0; j <= NUM_RAND_COLS; j++) {
    for (i=0; i < m_NumClasses; i++) {
      pseudoClassProbs[j][i]=0.0;
    }
  }
  for (i=0; i < m_NumInstances; i++) {
    if (m_Distances[i] < 0) {
      continue;
    }
 else {
      pstar=PStar(m_Distances[i],scale);
      tprob=pstar / m_ActualCount;
      avgprob+=tprob;
      if (pstar < minprob) {
        minprob=pstar;
      }
      for (k=0; k <= NUM_RAND_COLS; k++) {
        pseudoClassProbs[k][m_RandClassCols[k][i]]+=tprob;
      }
    }
  }
  for (j=m_NumClasses - 1; j >= 0; j--) {
    actClassProb=pseudoClassProbs[NUM_RAND_COLS][j] / avgprob;
    if (actClassProb > 0) {
      actent-=actClassProb * Math.log(actClassProb) / LOG2;
    }
  }
  for (k=0; k < NUM_RAND_COLS; k++) {
    for (i=m_NumClasses - 1; i >= 0; i--) {
      randClassProb=pseudoClassProbs[k][i] / avgprob;
      if (randClassProb > 0) {
        randent-=randClassProb * Math.log(randClassProb) / LOG2;
      }
    }
  }
  randent/=NUM_RAND_COLS;
  params.actEntropy=actent;
  params.randEntropy=randent;
  params.avgProb=avgprob;
  params.minProb=minprob;
}

private void calculateEntropy ( double scale , KStarWrapper params ) { int i , j , k ; double actent = 0.0 , randent = 0.0 ; double pstar , tprob , avgprob = 0.0 , minprob = 1.0 ; double actClassProb , randClassProb ; double [ ] [ ] pseudoClassProbs = new double [ NUM_RAND_COLS + 1 ] [ m_NumClasses ] ; for ( j = 0 ; j <= NUM_RAND_COLS ; j ++ ) { for ( i = 0 ; i < m_NumClasses ; i ++ ) { pseudoClassProbs [ j ] [ i ] = 0.0 ; } } for ( i = 0 ; i < m_NumInstances ; i ++ ) { if ( m_Distances [ i ] < 0 ) { continue ; } else { pstar = PStar ( m_Distances [ i ] , scale ) ; tprob = pstar / m_ActualCount ; avgprob += tprob ; if ( pstar < minprob ) { minprob = pstar ; } for ( k = 0 ; k <= NUM_RAND_COLS ; k ++ ) { pseudoClassProbs [ k ] [ m_RandClassCols [ k ] [ i ] ] += tprob ; } } } for ( j = m_NumClasses - 1 ; j >= 0 ; j -- ) { actClassProb = pseudoClassProbs [ NUM_RAND_COLS ] [ j ] / avgprob ; if ( actClassProb > 0 ) { actent -= actClassProb * Math . log ( actClassProb ) / LOG2 ; } } for ( k = 0 ; k < NUM_RAND_COLS ; k ++ ) { for ( i = m_NumClasses - 1 ; i >= 0 ; i -- ) { randClassProb = pseudoClassProbs [ k ] [ i ] / avgprob ; if ( randClassProb > 0 ) { randent -= randClassProb * Math . log ( randClassProb ) / LOG2 ; } } } randent /= NUM_RAND_COLS ; params . actEntropy = actent ; params . randEntropy = randent ; params . avgProb = avgprob ; params . minProb = minprob ; }
calculates several parameters aside from the entropy : for a specified scale factor , calculates the actual entropy , a random entropy using a randomized set of class value colomns , and records the average and smallest probabilities ( for use in missing value case ) .
