question: @ Reference ( authors = "D. Pelleg, A. Moore" , booktitle = "X-means: Extending K-means with Efficient Estimation on the Number of Clusters" , title = "Proceedings of the 17th International Conference on Machine Learning (ICML 2000)" , url = "http://www.pelleg.org/shared/hp/download/xmeans.ps" ) public static < V extends NumberVector > double logLikelihood ( 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 = 0. ; 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 += d_i [ i ] = varianceOfCluster ( cluster , distanceFunction , relation ) ; } if ( n <= m ) { return Double . NEGATIVE_INFINITY ; } final double v = d / ( n - m ) , logv = Math . log ( v ) ; double logLikelihood = 0. ; for ( int i = 0 ; i < m ; i ++ ) { logLikelihood += n_i [ i ] * Math . log ( n_i [ i ] ) - n_i [ i ] * .5 * MathUtil . LOGTWOPI - n_i [ i ] * dim * .5 * logv - ( d_i [ i ] - m ) * .5 ; } logLikelihood -= n * Math . log ( n ) ; return logLikelihood ; }
target:  Computes log likelihood of an entire clustering. Version as used in the X-means publication.