private double avgDistance ( double [ ] centroid , DBIDs objectIDs , Relation < V > database , int dimension ) { Mean avg = new Mean ( ) ; for ( DBIDIter iter = objectIDs . iter ( ) ; iter . valid ( ) ; iter . advance ( ) ) { V o = database . get ( iter ) ; avg . put ( Math . abs ( centroid [ dimension ] - o . doubleValue ( dimension ) ) ) ; } return avg . getMean ( ) ; }
Computes the average distance of the objects to the centroid along the specified dimension .