public void randomShuffleInPlace(){
  Random r=new Random();
  r.setSeed(FEATURE_VECTOR_RANDOM_SEED);
  int n=featureVectors.size();
  for (int i=n - 1; i >= 1; i--) {
    int j=r.nextInt(i + 1);
    int[] tmp=featureVectors.get(i);
    featureVectors.set(i,featureVectors.get(j));
    featureVectors.set(j,tmp);
    Integer tmpI=injectWhitespace.get(i);
    injectWhitespace.set(i,injectWhitespace.get(j));
    injectWhitespace.set(j,tmpI);
    tmpI=hpos.get(i);
    hpos.set(i,hpos.get(j));
    hpos.set(j,tmpI);
    InputDocument tmpD=documentsPerExemplar.get(i);
    documentsPerExemplar.set(i,documentsPerExemplar.get(j));
    documentsPerExemplar.set(j,tmpD);
  }
}

public void randomShuffleInPlace ( ) { Random r = new Random ( ) ; r . setSeed ( FEATURE_VECTOR_RANDOM_SEED ) ; int n = featureVectors . size ( ) ; for ( int i = n - 1 ; i >= 1 ; i -- ) { int j = r . nextInt ( i + 1 ) ; int [ ] tmp = featureVectors . get ( i ) ; featureVectors . set ( i , featureVectors . get ( j ) ) ; featureVectors . set ( j , tmp ) ; Integer tmpI = injectWhitespace . get ( i ) ; injectWhitespace . set ( i , injectWhitespace . get ( j ) ) ; injectWhitespace . set ( j , tmpI ) ; tmpI = hpos . get ( i ) ; hpos . set ( i , hpos . get ( j ) ) ; hpos . set ( j , tmpI ) ; InputDocument tmpD = documentsPerExemplar . get ( i ) ; documentsPerExemplar . set ( i , documentsPerExemplar . get ( j ) ) ; documentsPerExemplar . set ( j , tmpD ) ; } }
feature vectors in x are lumped together as they are read in each document . in knn , this tends to find features from the same document rather than from across the corpus since we grab k neighbors . for k = 11 , we might only see exemplars from a single corpus document . if all exemplars fit in k , this wouldn ' t be an issue . fisher - yates / knuth shuffling " to shuffle an array a of n elements ( indices 0 . . n - 1 ) " : https : / / en . wikipedia . org / wiki / fisher % e2 % 80 % 93yates_shuffle
