src/kmeans.cpp
// Choose one item at random to serve as the seed of each cluster
Choose one item at random to serve as the seed of each cluster
Choose one item at random to serve as the seed of each cluster
void KMeans::Seed1(void) {
  bool *used = new bool[num_objects_];
  for (int o = 0; o < num_objects_; ++o) used[o] = false;
  for (int c = 0; c < num_clusters_; ++c) {
    int o;
    do {
      o = RandBetween(0, num_objects_ - 1);
    } while (used[o]);
    used[o] = true;
    for (int f = 0; f < dim_; ++f) {
      means_[c][f] = objects_[o][f];
    }
  }
  delete [] used;
}
void KMeans :: Seed1 ( void ) { bool * used = new bool [ num_objects_ ] ; for ( int o = 0 ; o < num_objects_ ; ++ o ) used [ o ] = false ; for ( int c = 0 ; c < num_clusters_ ; ++ c ) { int o ; do { o = RandBetween ( 0 , num_objects_ - 1 ) ; } while ( used [ o ] ) ; used [ o ] = true ; for ( int f = 0 ; f < dim_ ; ++ f ) { means_ [ c ] [ f ] = objects_ [ o ] [ f ] ; } } delete [ ] used ; }
Choose one item at random to serve as the seed of each cluster
Choose one item at random to serve as the seed of each cluster