Figure 3 shows the results of tracking where the card that started on top ended up. At n=1 shuffles, there's roughly a 50% chance that the new top card is the original top card. When the deck is truly random, it should be equally likely that the original top card is at any position in the deck (1/52 chance of being anywhere, or about 1.923%). The probability distribution is certainly in that range at n=5 (varying from about 1% to 4%), but is still obviously oriented towards the top of the deck. Only at thirteen shuffles does the p value for a correlation between the original order and the distribution go above 0.05) (n=12 was p=.02, by the way). Statistical tests aside, the remaining order is pretty easy to pick out visually up to this point by the slope of the line. (Note the extent of the y-axis changes as you progress through the shuffle to highlight the remaining structure!) These results were based on a simulation of 1 million decks.\n", "
So, as you might expect, the number of shuffles to randomness depends on your definition of randomness. If I were betting on the top card, my chances of winning (though small for n>4) are better than average all the way up until the twelfth or thirteenth shuffle!" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "References\n", "
Bayer, D., & Diaconis, P. (1992). Trailing the dovetail shuffle to its lair. The Annals of Applied Probability, 2(2), 294-313.\n", "
Gilbert. (1995). Theory of shuffling (Technical memorandum): Bell Laboratories.\n", "
Trefethen, L. N., & Trefethen, L. M. (2000). How many shuffles to randomize a deck of cards? Proceedings of the Royal Society of London: A, 456(2002), 2561-2568." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.3" } }, "nbformat": 4, "nbformat_minor": 1 }