예제 #1
0
        public double Distance(KCluster cluster, quadPanel input)
        {
            //euclidean distance between centroid weights and input weights
            double d = Math.Pow(cluster.weightVector.X - input.weights[0], 2)
                       + Math.Pow(cluster.weightVector.Y - input.weights[1], 2)
                       + Math.Pow(cluster.weightVector.Z - input.weights[2], 2);

            return(Math.Sqrt(d));
        }
예제 #2
0
        quadPanel[] inputs;                  //input panels

        public KClusterGroup(int K, quadPanel[] inputs)
        {
            this.K = K;
            Random rnd = new Random();

            centroids = new KCluster[K];

            for (int i = 0; i < centroids.Length; i++)
            {
                int randomIndex = rnd.Next(centroids.Length);
                centroids[i] = new KCluster(inputs[randomIndex]);
            }
            this.inputs = inputs;

            //assign inputs to clusters for first time
            AssignClusters();
        }