private double logLikelihoodEstimate(int numInst,
protected double logLikelihoodEstimate(int numInst,
  private double logLikelihoodEstimate(int numInst, 				       Instance center, 				       double distortion, 				       int numCent) {    // R(n) num of instances of the center -> numInst    // K num of centers -> not used    //    //todo take the diff comments away    double loglike = 0;    /* if is new */    if (numInst > 1) {      /* diff variance is new */      //      // distortion = Sum over instances x of the center(x-center)      // different to paper; sum should be squared      //      // (Sum of distances to center) / R(n) - 1.0      // different to paper; should be R(n)-K      double variance =  distortion / (numInst - 1.0);         //      //  -R(n)/2 * log(pi*2)      //      double p1 = - (numInst / 2.0) * Math.log(Math.PI * 2.0);      /* diff	 thats how we had it	 double p2 = -((ni * center.numAttributes()) / 2) * distortion;      */      //      // -(R(n)*M)/2 * log(variance)       //      double p2 = - (numInst * center.numAttributes()) / 2 * Math.log(variance);            /* diff	 thats how we had it, the difference is a bug in x-means	 double p3 = - (numInst - numCent) / 2;      */      //      // -(R(n)-1)/2      //      double p3 = - (numInst - 1.0) / 2.0;            //      // R(n)*log(R(n))      //      double p4 = numInst * Math.log(numInst);            /* diff x-means doesn't have this part 	 double p5 = - numInst * Math.log(numInstTotal);      */            /*	loglike = -(ni / 2) * Math.log(Math.PI * 2) 	- (ni * center.numAttributes()) / 2.0) * logdistortion	- (ni - k) / 2.0 	+ ni * Math.log(ni) 	- ni * Math.log(r);      */      loglike = p1 + p2 + p3 + p4; // diff + p5;      //the log(r) is something that can be reused.      //as is the log(2 PI), these could provide extra speed up later on.      //since distortion is so expensive to compute, I only do that once.    }    return loglike;  }