示例#1
0
 /**
  * Creates a ClusteringFeature.
  *
  * @param center the center point
  * @param radius the radius
  */
 public ClusteringFeature(double[] center, double radius) {
   super(center, radius, 1);
   this.numPoints = 1;
   this.sumPoints = new double[center.length];
   System.arraycopy(center, 0, this.sumPoints, 0, center.length);
   this.sumSquaredLength = Metric.distanceSquared(center);
 }
示例#2
0
 /**
  * Calculates the k-means costs of the ClusteringFeature and a point too a center.
  *
  * @param center the center too calculate the costs
  * @param point the point too calculate the costs
  * @return the costs
  */
 public double calcKMeansCosts(double[] center, double[] point) {
   assert (this.sumPoints.length == center.length && this.sumPoints.length == point.length);
   return (this.sumSquaredLength + Metric.distanceSquared(point))
       - 2 * Metric.dotProductWithAddition(this.sumPoints, point, center)
       + (this.numPoints + 1) * Metric.dotProduct(center);
 }