# Thread: POW card counting game

1. ## POW card counting game

Hello all. Please forgive me if I do not post in accurate mathematical language. My last math was a beginning calculus course in 1979. My first dilemma is whether to post irrelevant background. I shall do so. Please skip to paragraph 3 if you do not care.

My son (5th year engineering senior at OSU) and I have been having a discussion lately about a game my Dad told me about from when he was a POW. He was shot down over Austria in 1943 and spent about 18 months locked up. Not much to do in an enemy prison camp, talk about food, think about food, dream about food. Substitute "girls" for "food". Repeat. Anyway, they did have cigarettes and cards. One of the things they did was a gambling game with the cards. The player pays one cigarette and takes the deck from the house. Turning over the top card the player counts "one." As long as the turned over card is not an Ace, the player continues. He turns over the second card and counts "two." As long as the turned over card is not a two, he continues, 1 through 13 and repeats 4 times. As long as he never turns over a card equal to his count, he wins and the house pays. Here is question part. My Dad told me house paid 25 to 1. I tried to convince him that he was being ripped off at that rate and he should always be the house. He insisted that he saw thousands of iterations of this and those odds were right on. I tried to convince him that there was chicanery involved, perhaps paying out too frequently to a confederate to encourage playing at unfavorable odds. I never convinced him, but never really new the right math to do it anyway.

So what is the probability of success for counting sequentially through a deck of cards (1-13 in order, repeat 4 times) and never turn over a card equal to your count. Early on I thought the odds were less than .01 but I progressed to where I thought it was (12/13)^52 or about 64 to 1. My son built a simple brute force excel spread sheet that after a few thousand iterations seems to suggest slightly longer odds around .0137. So what is the mathematically correct way to figure this out?

Thanks for you attention.

2. ## Re: POW card counting game

A Monte Carlo simulation like your son did can be useful in problems like this, but to have faith in its accuracy you really need to run more than a few thousand simulations. Given that you are trying to check whether p= 0.0156, if you run 2,000 simulations you would expect to win 31 games and the standard deviation is sqrt(np(1-p)) = 5.5; thus his results of 0.0137= 27 out of 2000 is less than 1 sigma from the expected value, which means his simulation does not prove you wrong.

3. ## Re: POW card counting game

In thinking about this problem some more I think I have an answer that yield odds almost precisely in agreement with your son's simulations. Consider first the aces in the deck - you lose if an ace shows up in position 1, 14, 27, or 40 in the deck. Thus there are 48 "good" spots for the four aces. The probability of the first ace being in one of those 48 good spots is 48/52. Now there are three aces left, and 47 remaining good spots out of the 51 remaining positions, so the probability of success with the second ace is 47/51. Continuing in this way we see that the probability of all 4 aces not being in any of the four losing positions is:

$\displaystyle P(\text{no Ace in positions 1, 14, 27, or 40}) = \frac {48 \times 47 \times 46 \times 45}{52 \times 51 \times 50 \times 49} = 0.718737$.

This is slighly lower result than your approach, which gives(12/13)^4 = 0.726025. By this same reasoning the probability of the four 2's not being in positions 2, 15, 28, or 41 is also 0.718737, and so on. Thus the probability of none of the cards being in a losing position is:

$\displaystyle P(\text{winning}) = \left( \frac {48 \times 47 \times 46 \times 45}{52 \times 51 \times 50 \times 49} \right)^{13} = 0.013659.$

Note that this is essentially the same answer as your son's simulation. The house should pay off about 73:1, not 25:1.

4. ## Re: POW card counting game

Excellent. Thank you for the analysis. You have effectively handled the "non-replacement" issue that troubled some of the people I have discussed this with. You have convinced me that this is the correct solution.
FYI, after 20020 runs our simulation yielded 275 wins for a success rate of 0.013736

5. ## Re: POW card counting game

Given that you are trying to check whether p= 0.0156, if you run 2,000 simulations you would expect to win 31 games and the standard deviation is sqrt(np(1-p)) = 5.5; thus his results of 0.0137= 27 out of 2000 is less than 1 sigma from the expected value, which means his simulation does not prove you wrong.
This really isn't the correct interpretation of those results. If you suspect that - on any one game - that the prob. of winning is p, and you are estimating it with p-hat (which is the result of the simulation), it's distribution has std. error sqrt[p(1-p)/n]. With 2000 simulations, that is a VERY fine confidence interval.

Also, the derivation of the answer isn't correct. The results of the P(Aces) is correct, but the second class of cards is dependent on where the first class of cards landed (the third even more so). The only way - say - P(Aces) = P(2's) is if the aces landed in the spots that the 2's could not be in (in which case you would still have 48 places with which to place your 2's).

The mathematical derivation is a bid convoluted, as there is no easy complement to take and then try and work your way back from there. Using computers is the easiest way to estimate this.

Using R with code:
Spoiler:

#Define Game Function
pow <- function(){
shuffle <- sample(rep(1:13,4), 52)
counting <- rep(1:13,4)
return(length(which(shuffle==counting)))
}

#Simulation results
game <- numeric()
for (i in 1:1000000){
game[i] <- ifelse(pow() !=0,0,1)
}

Gives me a sample proportion of 0.0165. The code is simple: sample from a deck of cards (denoted by their values), and compare to a string of 1 to 13 repeated 4 times. If any of the numbers match, you lose the game (and it is marked 0), otherwise 1.

6. ## Re: POW card counting game

I stand by my contention that the probability of winning the game is [(48*47*46*45)/(52*51*50*49)]^13 = (0.7187)^13 = 0.0137. I understand your point that the probability of success as you deal cards seems to be influenced by where the previous cards have landed - for example if all the aces land in the spots for the 2-cards (positions 2, 15, 28 and 41) then the 2's are guarranteed to successfully avoid landing in a 2-spot, so at first glance it may seem that the 2's have an improved chance of success over the 1's. But on the other hand if none of the 1's take a 2's position then the odds are worse for the 2's - their chance of success is reduced to (44*43*42*41)/(48*47*46*45)=0.6977. So depending on what's happened previously the chance of success for the 2's may be higher or lower than 07187. However, when you weight these probabilities of success by the probabilities of their being 0, 1, 2, 3, or 4 open positions for the 2's it all balances out to give the same result: the proabability of success for the 2's is 0.7187, just like for the 1's.

Here's the detailed analysis. To make it clearer we chance the circumstance a bit - after shuffling the deck we look for where the 1's are, themn we look for where the 2's are, then the 3's, etc. It's prettt clear from my previous post that when checking the 1's the chance ofsucces is (48*47*46*45)/(52*51*50*49). Now we want to determine the chance of success for the 2's:

A. Consider the case that none of the 1's took a 2's position. The probability that this happens is (48*47*46*45)/(52*51*50*49). With all four 2's open the probability that all four 2's will be in the remaining 44 open non 2-spots is (44*43*42*41)/(48*47*46*45). Hence the probability that none of the 1's end up in a 2's spot and none of the 2's end up in 2's spot is the product of these, or 0.5014.

B. Consider the case that one 1 takes a 2-spot, leaving 45 open non 2-spots for the 2's to land on. The probability that this happens is C(4,1)*(4*48*47*46)/(52*51*50*49). With three 2's open the probability that all four 2's will be in the remaining 45 open non-2 spaces is (45*44*43*42)/(48*47*46*45). Hence the probability that one of the 1's ends up in a 2's spot and none of the 2's end up in 2's spot is the product of these, or 0.1957.

C. Consider the case that two 1's take a 2-spot, leaving 46 open non 2-spots for the 2's to land on. The probability that this happens is C(4,2)*(4*3*48*47)/(52*51*50*49). With two 2's open the probability that all four 2's will be in the remaining 46 open non-2 spaces is (46*45*44*43)/(48*47*46*45). Hence the probability that two of the 1's ends up in a 2's spot and none of the 2's end up in 2's spot is the product of these, or 0.0210.

D. Consider the case that three 1's take a 2-spot, leaving 47 open non 2-spots for the 2's to land on. The probability that this happens is C(4,3)*(4*3*2*48)/(52*51*50*49). With one 2-spot open the probability that all four 2's will be in the remaining 47 open non-2 spaces is (47*46*45*44)/(48*47*46*45). Hence the probability that three of the 1's ends up in a 2's spot and none of the 2's end up in 2's spot is the product of these, or 0.00065.

E. Finally consider the case that all four 1's take the 2-spots, leaving 47 open non 2-spots for the 2's to land on. The probability that this happens is (4*3*2*1)/(52*51*50*49). With two 2's open the probability that all four 2's will be in the remaining 47 open non-2 spaces is (48*47*46*45)/(48*47*46*45)=1. Hence the probability that all four of the 1's ends up in a 2's spot and none of the 2's end up in 2's spot is the product of these, or 3.69E-6.

The overall weighted average of these probabilities is the sum of all five cases, which turns out to be 0.7187, the same as was the probability for success by the 1's].

If you repeat the exercise for dealing out 3's after the 1's and 2's have been dealt you end up with the same result. So bottom line is that the probability of winning the game is 0.7187^13.

7. ## Re: POW card counting game

ANDS! objection that "the second class of cards is dependent on where the first class of cards landed" seems to trip up a lot of people. It's not relevant to go halfway into the game and try to calculate the probability of any given card at that point. It doesn't matter how many 3's have fallen before turn 29, because I don't care about the odds of success at turn 29. The probability we are interested in is success at the last card. Plus Ebaines' derived answer of 0.0137 matches our experimental outcome.

I can't comprehend your code ANDS! but I am suspicious since it yields a different answer than our simulation.