Olivier Marty 8 жил өмнө
parent
commit
c8dff76a50
1 өөрчлөгдсөн 2 нэмэгдсэн , 2 устгасан
  1. 2 2
      src/permutation.cpp

+ 2 - 2
src/permutation.cpp

@@ -20,9 +20,9 @@ void permutation::transpose(int i, int j) {
 
 // TODO rapport : dire qu'on garde l'invariant pi[0] = 0
 void permutation::random() {
-  // Knuth shuffle
+  // Knuth Fisher Yates shuffle
   // there is a bias due to the use of rand()%_
-  for(int i = 1; i < size; i++)
+  for(int i = size-1; i > 1; i--)
     transpose(i, 1+rand()%i);
 }