## Saturday, June 19, 2010

### To bet or not to bet:: A Pairs card game

Question
Your friend offers to play a card game with you using a normal deck of 52 cards.  The rules of the game are that you'll turn over two cards at a time.  If the cards are both black, they go into his pile.  if they are both red, they go into your pile.  If there is one red and one black, they go into the discard pile.

You repeat the two card flipping until all 52 cards are used.  Whoever has more cards in their pile at the end wins.  But your friend also wins if there is a tie.  If you win, you get a dollar.  How much would bet on the game?

First of all its a trick if you get one pair of reds then 1 pair of blacks remain extra in the deck once all the cards are draw the game will always draw and your friend will always win.

That wasn't interesting. SO...

Assuming that we use a casino deck with a random mix of cards and we draw a random number of cards..

First consider the risk analysis;
P(Win)*Reward - P(Lose)*Bet > 0
Hence: Bet < Reward*P(Win)/P(lose)

Now the odds:
Lets simplify it we divide the 52 cards into 26 pairs. Each pair has four possibles BB, BR, RB, RR. The pairs all have the same chance of occurring.

So in terms of the score
+1 has 25%
0 has 50%
-1 has 25%

Lets start small;
If there is only 1 pair
then you have 25% chance of wining
and 50% + 25% = 75% chance of losing.

Since Bet < Reward*P(Win)/P(lose)
Bet < 1* (1/4)/(3/4)
< 1/3

Hence you need to bet less than 33 cents against a dollar to come out on top.

As you can see above the only number that really counts is the probability of 0. Since the remaining chance splits evenly between you and your friend

So if there are 2 pairs. the possible 0 end scores become
0,0  => 1 way at 0.5^2
+1,-1 => 2 ways at 0.25^2

The permutations are; +-, -+

Total = 1/2^2 + 2*1/4^2
= 1/4 + 2/16
= 4/16 + 2/16
= 6/16
The remaining chance 10/16 splits evenly resulting in;
Chance to win 5/16
Chance to lose 11/16

Since Bet < Reward*P(Win)/P(lose)
Bet < 1* (5/16)/(11/16)
< 5/11
< 0.45
ie bet less than 45 cents to come out on top..

if there are 3 pairs then
000 => 1 way 0.5^3
+0- => nCr(3,1)=3 possible places for +1, leaving nCr(2,1)=2 places for -1
=> hence there are 3*2=6 ways total

They are:
+-0, +0-
0+-, -+0
-0+, 0-+

Total = 1 * 0.5^3 + 6 * 0.25^2 * 0.5
= 1/8 + 6/32
= 1*4/32 + 6*1/32
= 10/32

That leaves 22/32 which splits equally between you and your friend..
Chance to win 11/32
Chance to lose 21/32

Since Bet < Reward*P(Win)/P(lose)
Bet < 1* (11/32)/(21/32)
< 11/21
< 0.52
ie bet less than 52 cents to come out on top..

If there are 4 pairs
0000 => nCr(4,0)=1 arrangements of +, and nCr(4,4)=1 for 0s giving a total of  1 way 0.5^3
+00- => nCr(4,1)=4 possible arrangements for the +, leaving nCr(3,2)=3 arrangements for the 0
=> hence there are 4*3 = 12 ways total at 0.5^2 * 0.25^2

+00-, +0-0 ,+-00
0+0-, 0+-0, -+00
00+-, 0-+0, -0+0
00-+, 0-0+, -00+

++-- => nCr(4,2)=6 possible arrangements for +, leaving nCr(3,0)=1 arrangements for the 0
=> hence there are 6*1 ways total at 0.25^4

++--, +-+-, +--+, -++-,-+-+, --++

Total = (1 * 0.5^4) + (12 * 0.5^2*0.25^2) + (6 * 0.25^4)
= 1/16 + 12/(16*4) + 6/256
= 1*16/256 + 12*4/256 + 6*1/256
= (16+48+6)/256
= 70/256

That leaves 186/256 which splits equally between you and your friend..
Chance to win 93/256
Chance to lose 163/256

Since Bet < Reward*P(Win)/P(lose)
Bet < (93/256)/(163/256)
< 93/163
< 0.57
ie bet less than 57 cents to come out on top..

Ok so now lets generalize it. for the number of pairs n the probability of 0;
Denominator is always 4^n
Numerator is always Sum( 4^(n-2i) * nCr(n,i) * nCr(n-i, n-2i ) ) where i = floor(n/2) ... 0

Thus
P(0) = Sum(...) / 4^n

Therefore the
Chance to win = (1 - P(0) ) /2
Chance to lose = (1 - P(0) ) /2 + P(0)
= (1 + P(0) ) /2

Since Bet < Reward*P(Win)/P(lose)
Bet <  (1 - P(0) ) /2 / (1 + P(0) ) /2
<  (1 - P(0) ) / (1 + P(0) )
< (4^n - Sum(...) ) / (4^n + Sum(...))

Hence with the 26 pairs case the p(0) becomes 0.11 and the bet increases to < 0.80  cents

 pairs p(0) Bet 1 0.5 0.333 2 0.375 0.4545 3 0.3125 0.52381 4 0.273438 0.570552 5 0.246094 0.605016 6 0.225586 0.631873 7 0.209473 0.653613 8 0.196381 0.671709 9 0.185471 0.687084 10 0.176197 0.700395 13 0.154981 0.73163 16 0.13995 0.754463 19 0.128585 0.77213 22 0.119604 0.786346 26 0.110116 0.801613