Browse Source

Fix permutation::random

Olivier Marty 8 years ago
parent
commit
c8dff76a50
1 changed files with 2 additions and 2 deletions
  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);
 }