double GetCentroidMinDistance(Song song, List <Song> centroids, IDistanceFunc distanceFunc) { double minDistance = distanceFunc.GetDistance(song, centroids[0]); for (int centroidIndex = 0; centroidIndex < centroids.Count; centroidIndex++) { minDistance = Math.Min(minDistance, distanceFunc.GetDistance(song, centroids[centroidIndex])); } return(minDistance); }
void AnalyzeInterClusterDistance() { List <Song> centroids = Model.Centroids; int clustersCount = centroids.Count; if (clustersCount == 0) { throw new ArgumentException("No clusters."); } const string id = "centroids_center"; Song centroidsCenter = centroids[0].CloneCleared(id); for (int i = 1; i < clustersCount; i++) { Song centroid = centroids[i]; centroidsCenter.Add(centroid); } centroidsCenter.Divide(clustersCount); IDistanceFunc distanceFunc = Model.DistanceFunc; InterClusterMeanDistance = 0.0; foreach (Song centroid in centroids) { InterClusterMeanDistance += distanceFunc.GetDistance(centroid, centroidsCenter); } InterClusterMeanDistance /= clustersCount; }