code: private double bic(int n, int d, double distortion) {
          double variance = distortion / (n - 1);
  
          double p1 = -n * LOG2PI;
          double p2 = -n * d * Math.log(variance);
          double p3 = -(n - 1);
          double L = (p1 + p2 + p3) / 2;
  
          int numParameters = d + 1;
          return L - 0.5 * numParameters * Math.log(n);
      }
docs: Calculates the BIC for single cluster.
  @param n the total number of samples.
  @param d the dimensionality of data.
  @param distortion the distortion of clusters.
  @return the BIC score.