Thursday, October 16, 2008

random permutations

1. Get 10 random numbers between 0 and 1 using the rand function
2. sort them in decreasing (or increasing) order
3. assign to each number its rank
4. replace in the original list, the random numbers by their ranks

Now you have a random permutation, where every permutation is equally likely.

No comments: