Skip to forum
How Random is Rando...
 
Notifications
Clear all

How Random is Random?

1 Posts
1 Users
0 Reactions
192 Views
Super Moderator
VorpalF2F
Joined: 02.09.2010

Testing Some Theory

How many times would you have to select a card, before all cards were selected an equal number of times?

You have all seen the poker variance calculator — and if you haven't, click the link now, and play with it. It shows just how badly things can go — even for a player with a decent winrate.

In the process of trying to figure out the chances of success in 888's "cardstrike" promotion[1] I wrote a simulation that selected cards in pairs.
The chances of drawing any card are of course 1/52
How many times would you need to draw before all cards were drawn an equal number of times?
I was drawing the cards in pairs, because I also noticed in my simulation that hitting two cards at once didn't match the expected value.

The Theory
If you draw two cards, trying to match two cards, there are 50 cards in the deck that match neither, and there are C(50,2)[2] or 1225 pairs that match neither of the two target cards, and there are C(52,2) or 1326 pairs of cards in total.
Since there are 1326 pairs, then one and only one combination will match the two target cards.
Therefore 1326-1225 = 101 pairs that match just one.

Here is the results of 250,000,000 trials. Since in each trial 4 cards are drawn, there were 1 billion selections total.
More on that later.
                      Actual  Theoretical      difference 
 0  230959622  0.92383848800  0.923831071   0.00000741711 
 1   18851630  0.07540652000  0.075414781  -0.00000826130 
 2     188748  0.00075499200  0.000754148   0.00000084419 

The actual and theoretical values are close, but not nearly as close as I expected.
They're good to better than 1 part in a 1000 though.

Now for Individual cards
I ran several simulations of 250,000,000 simulations each, with 4 cards selected each time.
I kept track of how many times each card was selected, and plotted the distribution of values.
I expected that the number of times drawn for each card would be fairly close to the average.
What is "fairly close".
Here is the giraffe:

The central line is the mean — and it is exactly the theoretical average.
The green lines are 1 standard deviation and the blue lines represent two, based on the middle curve.
The highest curve represents the results when I used the "cryptographic" random number generator, which is supposed to be secure enough to generate security tokens. The fact that the results are somewhat closer together suggests that this is true.

[1] see: https://forums.pokerstrategy.com/forum/thread.php?postid=3402567#post3402567
[2] C(50,2) is read as "Combinations of 50 cards taken 2 at a time"


Reply
Quote