@Override public void setTo( GrowQueue_F64 original ) { resize(original.size); System.arraycopy(original.data, 0, data, 0, size()); }
@Override public void setTo( GrowQueue_F64 original ) { resize(original.size); System.arraycopy(original.data, 0, data, 0, size()); }
/** * Randomly selects the next seed. The chance of a seed is based upon its distance * from the closest cluster. Larger distances mean more likely. * @param points List of all the points * @param target Number from 0 to 1, inclusive * @return Index of the selected seed */ protected final double[] selectNextSeed( List<double[]> points , double target ) { // this won't select previously selected points because the distance will be zero // If the distance is zero it will simply skip over it double sum = 0; for (int i = 0; i < distance.size(); i++) { sum += distance.get(i); double fraction = sum/totalDistance; if( fraction >= target ) return points.get(i); } throw new RuntimeException("This shouldn't happen"); }
/** * Randomly selects the next seed. The chance of a seed is based upon its distance * from the closest cluster. Larger distances mean more likely. * @param points List of all the points * @param target Number from 0 to 1, inclusive * @return Index of the selected seed */ protected final double[] selectNextSeed( List<double[]> points , double target ) { // this won't select previously selected points because the distance will be zero // If the distance is zero it will simply skip over it double sum = 0; for (int i = 0; i < distance.size(); i++) { sum += distance.get(i); double fraction = sum/totalDistance; if( fraction >= target ) return points.get(i); } throw new RuntimeException("This shouldn't happen"); }
/** * Updates the list of distances from a point to the closest cluster. Update list of total distances */ protected final void updateDistances( List<double[]> points , double []clusterNew ) { totalDistance = 0; for (int i = 0; i < distance.size(); i++) { double dOld = distance.get(i); double dNew = StandardKMeans_F64.distanceSq(points.get(i),clusterNew); if( dNew < dOld ) { distance.data[i] = dNew; totalDistance += dNew; } else { totalDistance += dOld; } } }
/** * Updates the list of distances from a point to the closest cluster. Update list of total distances */ protected final void updateDistances( List<double[]> points , double []clusterNew ) { totalDistance = 0; for (int i = 0; i < distance.size(); i++) { double dOld = distance.get(i); double dNew = StandardKMeans_F64.distanceSq(points.get(i),clusterNew); if( dNew < dOld ) { distance.data[i] = dNew; totalDistance += dNew; } else { totalDistance += dOld; } } }