private void calculateSphereSize(double scale,KStarWrapper params){
  int i;
  double sphereSize, minprob=1.0;
  double pstar;
  double pstarSum=0.0;
  double pstarSquareSum=0.0;
  double inc;
  for (i=0; i < m_NumInstances; i++) {
    if (m_Distances[i] < 0) {
      continue;
    }
 else {
      pstar=PStar(m_Distances[i],scale);
      if (minprob > pstar) {
        minprob=pstar;
      }
      inc=pstar / m_ActualCount;
      pstarSum+=inc;
      pstarSquareSum+=inc * inc;
    }
  }
  sphereSize=(pstarSquareSum == 0 ? 0 : pstarSum * pstarSum / pstarSquareSum);
  params.sphere=sphereSize;
  params.avgProb=pstarSum;
  params.minProb=minprob;
}

private void calculateSphereSize ( double scale , KStarWrapper params ) { int i ; double sphereSize , minprob = 1.0 ; double pstar ; double pstarSum = 0.0 ; double pstarSquareSum = 0.0 ; double inc ; for ( i = 0 ; i < m_NumInstances ; i ++ ) { if ( m_Distances [ i ] < 0 ) { continue ; } else { pstar = PStar ( m_Distances [ i ] , scale ) ; if ( minprob > pstar ) { minprob = pstar ; } inc = pstar / m_ActualCount ; pstarSum += inc ; pstarSquareSum += inc * inc ; } } sphereSize = ( pstarSquareSum == 0 ? 0 : pstarSum * pstarSum / pstarSquareSum ) ; params . sphere = sphereSize ; params . avgProb = pstarSum ; params . minProb = minprob ; }
calculates the size of the " sphere of influence " defined as : sphere = sum ( p ) ^ 2 / sum ( p ^ 2 ) where p ( i ) = root * exp ( - 2 * i * root ) . since there are n different training instances we multiply p ( i ) by 1 / n .
