code: private static double logLikelihood(int k, int n, int ni, int d, double variance) {
          double p1 = -ni * LOG2PI;
          double p2 = -ni * d * Math.log(variance);
          double p3 = -(ni - k);
          double p4 = ni * Math.log(ni);
          double p5 = -ni * Math.log(n);
          double loglike = (p1 + p2 + p3) / 2 + p4 + p5;
          return loglike;
      }
docs: Estimate the log-likelihood of the data for the given model.
  
  @param k the number of clusters.
  @param n the total number of samples.
  @param ni the number of samples belong to this cluster.
  @param d the dimensionality of data.
  @param variance the estimated variance of clusters.
  @return the likelihood estimate