I have seen many algorithms for generating random numbers, so I wondered what common algorithms exist for scrambling a set of given numbers (or objects).
The numbers or objects need not be in any particular order (e.g. $1,2,3, ..., n$).
There are several online shuffling programs and some are part of common programs such as Excel. So I am interested in:
- well-known shuffling algorithms
- how they compare to the expected number of fixed points (i.e. rencontres numbers, I believe)
- any known issues with such algorithms
- any known comparisons, e.g. Excel's number shuffler versus Python's
Fisher Yates is a proper (uniform) shuffle and efficient. Uniform in that all permutations are created equally.
It has been around since 1938 but a few poker sites got it wrong and it was exploited.
There are n! permutations and Fisher mimics that.
Issues are if random is not random. Don't create a new random with each shuffle and shuffle from the prior shuffle (not a clean deck). Unless they knew the initial seed they could not pick up a pattern (without a LOT of hands - like approaching infinity).
A common problem is actually too many permutations and some are produced more than others. For example, swap every element with every other element (no j ≤ i).
Another problem is not allow a card to stay in its current position. If ace spades came off first then it cannot come off first next time.