@Reference(authors="Q. Zhao, M. Xu, P. Fränti",title="Knee Point Detection on Bayesian Information Criterion",booktitle="20th IEEE International Conference on Tools with Artificial Intelligence",url="http://dx.doi.org/10.1109/ICTAI.2008.154") public static <V extends NumberVector>double logLikelihoodAlternate(Relation<V> relation,Clustering<? extends MeanModel> clustering,NumberVectorDistanceFunction<? super V> distanceFunction){
  List<? extends Cluster<? extends MeanModel>> clusters=clustering.getAllClusters();
  final int dim=RelationUtil.dimensionality(relation);
  final int m=clusters.size();
  int n=0;
  int[] n_i=new int[m];
  double[] d_i=new double[m];
  Iterator<? extends Cluster<? extends MeanModel>> it=clusters.iterator();
  for (int i=0; it.hasNext(); ++i) {
    Cluster<? extends MeanModel> cluster=it.next();
    n+=n_i[i]=cluster.size();
    d_i[i]=varianceOfCluster(cluster,distanceFunction,relation);
  }
  double logLikelihood=0.;
  for (int i=0; i < m; i++) {
    logLikelihood+=n_i[i] * Math.log(n_i[i] / (double)n) - n_i[i] * dim * .5* MathUtil.LOGTWOPI - n_i[i] * .5 * Math.log(d_i[i]) - (n_i[i] - m) * .5;
  }
  return logLikelihood;
}

@ Reference ( authors = "Q. Zhao, M. Xu, P. Fränti" , title = "Knee Point Detection on Bayesian Information Criterion" , booktitle = "20th IEEE International Conference on Tools with Artificial Intelligence" , url = "http://dx.doi.org/10.1109/ICTAI.2008.154" ) public static < V extends NumberVector > double logLikelihoodAlternate ( Relation < V > relation , Clustering < ? extends MeanModel > clustering , NumberVectorDistanceFunction < ? super V > distanceFunction ) { List < ? extends Cluster < ? extends MeanModel > > clusters = clustering . getAllClusters ( ) ; final int dim = RelationUtil . dimensionality ( relation ) ; final int m = clusters . size ( ) ; int n = 0 ; int [ ] n_i = new int [ m ] ; double [ ] d_i = new double [ m ] ; Iterator < ? extends Cluster < ? extends MeanModel > > it = clusters . iterator ( ) ; for ( int i = 0 ; it . hasNext ( ) ; ++ i ) { Cluster < ? extends MeanModel > cluster = it . next ( ) ; n += n_i [ i ] = cluster . size ( ) ; d_i [ i ] = varianceOfCluster ( cluster , distanceFunction , relation ) ; } double logLikelihood = 0. ; for ( int i = 0 ; i < m ; i ++ ) { logLikelihood += n_i [ i ] * Math . log ( n_i [ i ] / ( double ) n ) - n_i [ i ] * dim * .5 * MathUtil . LOGTWOPI - n_i [ i ] * .5 * Math . log ( d_i [ i ] ) - ( n_i [ i ] - m ) * .5 ; } return logLikelihood ; }
computes log likelihood of an entire clustering . version as used by zhao et al .
