private void setInitialCentroids() { //kn = (round((max-min)/k)*n)+min where n is from 0 to (k-1). double cx = 0, cy = 0; for (int n = 1; n <= clusters.Length; n++) { cx = (((getMaxXValue() - getMinXValue()) / (clusters.Length + 1)) * n) + getMinXValue(); cy = (((getMaxYValue() - getMinYValue()) / (clusters.Length + 1)) * n) + getMinYValue(); Centroid c1 = new Centroid(cx, cy); clusters[n - 1].setCentroid(c1); c1.setCluster(clusters[n - 1]); } }
public double testEuclideanDistance(Centroid c) { return(Math.Sqrt(Math.Pow((mX - c.getCx()), 2) + Math.Pow((mY - c.getCy()), 2))); }
public void setCentroid(Centroid c) { mCentroid = c; }
public Cluster(String name) { this.mName = name; this.mCentroid = null; //will be set by calling setCentroid() mDataPoints = new List <DataPoint>(); }