Problem Description
{A viewer recently pointed out that the existing shuffle
procedure used in
DFF programs is statistically invalid. Shuffling consists of exchanging each
card in a deck one time with another randomly selected card. My current
version selects the random card from anywhere in the deck. The proposed
"correct" procedure selects the random card only from those that have not yet
been exchanged.
Being of curious mind, I had to convince myself that it makes a difference.
The bottom line is that it does make a difference for a single shuffle of
and un-shuffled deck. If the deck is shuffled 3 or 4 times, the methods are
equally random.

Background & Techniques
The program starts with an ordered decked and shuffles a specified number
of times. The the long run, for a valid methodology, the card value for any
position in the deck is equally likely to be any card, so the expected value
of
of the card in any position is the mean value of all the cards. After each
shuffle, we'll plot the mean card value for each card position vs. the
positions and should see the chart move toward a straight line at the mean
card value.
We'll also display a measure of how the observed mean values vary from the
expected means.
The sum of the squared differences between the observed mean values and
the expected value across all card positions. This should approach zero the
number of shuffles increases, and does for the corrected procedure.
Most of the ideas for this program came from an old Pascal program to
illustrate his excellent discussion of right and wrong ways to shuffle;
Check
http://www.merlyn.demon.co.uk/pas-rand.htm#Shuf.
I'm still trying to rationalize the observed results. The old method, on
average,
is slightly more likely to leave cards that start toward the end of the deck
still toward the end of the deck after shuffling.
Running/Exploring the Program
|
Original Date: August 21,2006 |
Modified:
November 07, 2008 |
|