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 .