public double CalculateCodebookError() { int vectorCount = this.initialCluster.Size; //empty the clusters of their current members for (int c = 0; c < this.CodeSize; c++) { this.Clusters[c].ResetMembers(); } double error = 0.0; for (int v = 0; v < vectorCount; v++) { double[] euclidDist = new double[this.CodeSize]; for (int c = 0; c < this.CodeSize; c++) { euclidDist[c] = this.Clusters[c].DistanceFromCentroid(this.initialCluster.Vectors[v]); } int minID = DataTools.GetMinIndex(euclidDist); error += euclidDist[minID]; this.Clusters[minID].Vectors.Add(this.initialCluster.Vectors[v]); } error /= vectorCount; return(error); }