Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Shuffling
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Algorithms== {{Main|Fisher–Yates shuffle}} If a computer has access to purely random numbers, it is capable of generating a "perfect shuffle", a [[random permutation]] of the cards; beware that this terminology (an algorithm that perfectly randomizes the deck) differs from "a perfectly executed single shuffle", notably a perfectly interleaving [[faro shuffle]]. The [[Fisher–Yates shuffle]], popularized by [[Donald Knuth]], is simple (a few lines of code) and efficient ([[big O notation|O]](''n'') on an ''n''-card deck, assuming constant time for fundamental steps) algorithm for doing this. Shuffling can be seen as the opposite of [[sorting algorithm|sorting]]. A new alternative to Fisher-Yates, which does not use any array memory operations, is the use a Pseudo Random Index Generator (PRIG) function algorithm. There are other, less-desirable algorithms in common use. For example, one can assign a random number to each card, and then sort the cards in order of their random numbers. This will generate a random permutation, unless any of the random numbers generated are the same as any others (i.e. pairs, triplets etc.). This can be eliminated either by adjusting one of the pair's values randomly up or down by a small amount, or reduced to an arbitrarily low probability by choosing a sufficiently wide range of random number choices. If using efficient sorting such as [[mergesort]] or [[heapsort]] this is an [[big O notation|O]](''n'' log ''n'') average and worst-case algorithm. ===Online gambling=== These issues are of considerable commercial importance in [[online gambling]], where the randomness of the shuffling of packs of simulated cards for online card games is crucial. For this reason, many online gambling sites provide descriptions of their shuffling algorithms and the sources of randomness used to drive these algorithms, with some gambling sites also providing auditors' reports of the performance of their systems.{{Citation needed|date=December 2015}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)