estebanrey
estebanrey
  • Threads: 4
  • Posts: 40
Joined: Oct 4, 2012
February 22nd, 2013 at 3:54:07 AM permalink
Hi all,

I think I may have 'corrected' a Professor of Mathematics at Cambridge University (UK) but I'd like all the evil geniuses here to check my working before he replies.

First of all, you might want to watch these two videos that explain "the game", firstly this trick to get free beer is explained here...

http://www.youtube.com/watch?v=B7MOlKQCPmE (4:40 onward)

He claims the odds of getting any two values at some point being together is 'way over 50%'. However Dr James Grime disagrees, here is his response here...

http://www.youtube.com/watch?v=1WJyEQXZ7dY

If you can't watch the video the question basically is "What are the odds that two randomly picked values will appear together in a shuffled deck of cards".

Now I agree in principle with Dr Grime, the chance of 'winning' isn't over 50% as claimed in the Scam School video, but I disagree with his 48.3% figure, I make it 1 percentage point higher at 49.3% So who is correct?

Well, here is my explanation. Firstly, the only way (in my mind) of calculating this is to work out the chance of losing, what I'm am going to do is choose the 'Jack' and the 'King' for my example. If we concentrate on the Jacks, and mentally go through the deck arriving at each one and working out the chances of losing at each stage. There are 8 stages as each of the 4 Jacks could have a King immediately before it or immediately after it to win.

Here is my complete working.....

STAGE CARD POSSIBILITIES CARD POSS' NO. LOSING POSSIBILITIES STAGE % LOSE RUNNING % LOSE
King precedes 1st Jack AAAA22223333444455556666777788889999TTTTQQQQKKKK 48 44 91.67% 91.67%
King follows 1st Jack AAAA22223333444455556666777788889999TTTTJJJQQQQKKKK 51 47 92.16% 84.48%
King precedes 2nd Jack AAAA22223333444455556666777788889999TTTTJQQQQKKKK 49 45 91.84% 77.58%
King follows 2nd Jack AAAA22223333444455556666777788889999TTTTJJQQQQKKKK 50 46 92% 71.37%
King precedes 3rd Jack AAAA22223333444455556666777788889999TTTTJQQQQKKKK 49 45 91.84% 65.55%
King follows 3rd Jack AAAA22223333444455556666777788889999TTTTJQQQQKKKK 49 45 91.84% 60.2%
King precedes 4th Jack AAAA22223333444455556666777788889999TTTTJQQQQKKKK 49 45 91.84% 55.28%
King follows 4th Jack AAAA22223333444455556666777788889999TTTTQQQQKKKK 48 44 91.67% 50.68%



And now my stage-by-stage explanation for it...

King immediately precedes the 1st Jack
At the first Jack, the chance of a King NOT being before it is 44 in 48, since we can eliminate the four Jacks as possibilities because you've stopped on the first one, leaving 48 possible cards left. Then there are four Kings in which you'd win leaving 44 losing cards. Hence a 44/48 chance of a loss at this stage. At every stage the number of losing cards is the number of possible cards minus 4.

King immediately follows the 1st Jack
The chance a King won't appear right after the first Jack is 47 in 51, since we can eliminate the Jack you are looking at from the total possibilities but the next three Jacks are included as they could follow it if you have two Jacks in a row, leaving 47 losing cards out of the 51 possible cards.

King immediately precedes the 2nd Jack
On the 2nd Jack you come to, the chance a King isn't before it is 45 in 49, it's the same reasoning as the first Jack only this time the 'before' losing possibility changes as you need to add back in the possibility you have two Jacks in a row which obviously isn't possible on the first Jack. From this point forward the odds of a King immediately preceding a Jack will stay at 45 in 49 (as you can discount the Jacks you haven't got to yet and the ones you've gone past except the last).

King immediately follows the 2nd Jack
The chance a King won't immediately follow the 2nd Jack is 46 in 50, since the first 2 Jacks have to be eliminated from the possibilities leaving 50 cards, then we again discount the winning 4 Kings to get the number of losing cards.

King immediately precedes the 3rd Jack
As stated this is always 45 in 49 now, this time we discount the 1st, 3rd and 4th Jacks from the possibilities (the 2nd Jack could precede the 3rd though) leaving again 49 cards, with 45 of them losing.

King immediately follows the 3rd Jack
The chance a King won't immediately follow the 3rd Jack is also 45 in 49 (since the first 3 Jacks aren't available leaving 49 possible cards, and we minus the four winning 4 Kings to get the 45 losers.

King immediately precedes the 4th Jack
Again this is 45 in 49 now, this time we discount the 1st, 2nd and 4th Jacks from the possibilities (the 3rd Jack could precede the 4th though) leaving again 49 cards, with 45 of them losing.

King immediately follows the 4th Jack
Finally the chance of the 4th Jack NOT having a King right after it is 44 in 48, since it can't any of the 4 Jacks as there are none left to follow it leaving 48 possible cards, with 44 of them losers.

So.. the final equation to work out the odds of losing all 8 stages is this...

(44/48) * (47/51) * (45/49) * (46/50) * (45/49) * (45/49) * (45/49) * (44/48) = 50.68%.

Thus by definition the chance of winning the game is 49.32%

Do you agree with me, or the professor? Maybe neither of us are right?
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6679
Joined: Jun 22, 2011
February 22nd, 2013 at 1:03:24 PM permalink
Did you remember to take into account (a) the possibility of the first and/or last cards being a Jack (if it's the first card, then obviously there can't be a King before it), and (b) the possibility of two or more Jacks being together in the deck?
estebanrey
estebanrey
  • Threads: 4
  • Posts: 40
Joined: Oct 4, 2012
February 22nd, 2013 at 3:13:53 PM permalink
Yes on both counts, the latter point (b) is why the odds chances for the 'before' stage on the first Jack is 48 out of 44 (since the first Jack can't have a Jack before it) and 49 out of 45 from the 2nd Jack then on (as the Jacks that haven't come up yet must be discounted as well as the ones before it EXCEPT the last one) In short it the same as before plus one as you're adding in the possibility of two Jacks following each other.

As for (a) there can be a King before it as I was concentrating on Jacks and only checking when I come to one. I am looking at the before and after (a Jack) which I believe that covers the two possibilities of either a Jack or King appearing first/Last in directly.

If I looked at it from the King's point of view, I'd get the same result but if I multiplied the two together it would be wrong as I'd be considered each 'winning' permutation twice. My maths already cover both KJ and JK which are the only two possibilities of winning combinations.
ThatDonGuy
ThatDonGuy
  • Threads: 122
  • Posts: 6679
Joined: Jun 22, 2011
February 22nd, 2013 at 4:10:42 PM permalink
Quote: estebanrey

Yes on both counts, the latter point (b) is why the odds chances for the 'before' stage on the first Jack is 48 out of 44 (since the first Jack can't have a Jack before it) and 49 out of 45 from the 2nd Jack then on (as the Jacks that haven't come up yet must be discounted as well as the ones before it EXCEPT the last one) In short it the same as before plus one as you're adding in the possibility of two Jacks following each other.


But if you have two Jacks together, your calculation of "47 cards out of 51 not being a King" following the first Jack and "46 cards out of 50 not being a King" preceding the second Jack aren't independent. I don't think you can simply multiply those two fractions together.

I did a brute force calculation, and got 48.627904%.
(Here's how: let C(a,b) denote the number of combinations of a items taken b at a time. There are C(52,4) ways that the Kings can be arranged in the deck (disregarding suits). For each one, let X be the number of combinations that are not next to a King. There are C(48,4) ways to place the Jacks, and C(X,4) ways to place the Jacks such that none of them are next to a King, so, for that particular combination of the four Kings, the probability that at least one Jack is next to a King = 1 - C(X,4)/C(48,4). Since each of the C(52,4) arrangements of the Kings is equally likely, the total probability = the sum of the individual probabilities / C(52,4).)
EdCollins
EdCollins
  • Threads: 20
  • Posts: 1739
Joined: Oct 21, 2011
February 23rd, 2013 at 8:35:32 AM permalink
I also believe the answer is very close to .4862. Good work Don.

I also wrote a computer program to simulate this trick. I simulated the trick 100 million times. (My program only takes a few minutes to run through this many trials.)

Based upon hundreds of other simulations I've written, involving cards, dice, roulette spins, etc., I know that 100 million trials is enough trials to come VERY close to the true percentage.

My simulation indicates a winning probability of .48627224. (Naturally, subsequent 100 million trial runs gave similar answers.)
7craps
7craps
  • Threads: 18
  • Posts: 1977
Joined: Jan 23, 2010
February 23rd, 2013 at 10:00:26 AM permalink
Quote: EdCollins

Based upon hundreds of other simulations I've written, involving cards, dice, roulette spins, etc., I know that 100 million trials is enough trials to come VERY close to the true percentage.

My simulation indicates a winning probability of .48627224.
(Naturally, subsequent 100 million trial runs gave similar answers.)

For binomial trials we can use a simple formula
(found in many prob/stats books like Understanding Probability by Henk Tjims page 175)
to calculate the error for the value of P from a number of sims run (point estimate)
(error= chance that the value of P from the sim lies outside an interval)
error = z-score*sqrt(p*(1-p)/sims)

Say, 3.29 (z-score) would be the 99.9% confidence level (interval)
stating that the probability of P falling outside the 99.9% range (P+/-) would be 1 in 1000
For a greater CL we just need to run more sims
p	0.48627224
error 0.000164464 (about 1 in 6,000)
p-error 0.486107776
p+error 0.486436704
sims 100,000,000
So the true probability of P for 100 million simulations lies between p-error and p+error
with only a small chance (1 in 6000) that it lies outside that interval.

(we can also calculate the number of sims to run to have a specific error with a specific confidence level (interval)
by re-arranging the formula above)
(z_score/error)^2*(p*(1-p))
error could be 0.01, 0.001, 0.0001 etc.
The rule of thumb is if we want to cut our error in half we need about 4x as many sims to accomplish that
Increasing the simulation by 100x increases the accuracy by a factor of only 10 (moves the decimal point just over one to the right. .001 to .001)
To have the error be .0001 (z-score 3.89, 1 in 10,000, CL 99.99%) for the EC 100 million sim run, we would need a minimum of 378,132,377 sims.
So nice to have spreadsheets, so I think I did the math correctly
winsome johnny (not Win some johnny)
estebanrey
estebanrey
  • Threads: 4
  • Posts: 40
Joined: Oct 4, 2012
February 24th, 2013 at 5:40:00 PM permalink
Quote:

Did you remember to take into account (a) the possibility of the first and/or last cards being a Jack (if it's the first card, then obviously there can't be a King before it), and (b) the possibility of two or more Jacks being together in the deck?



Oops didn't read this properly the first time. Yes that's where I went wrong, when looking for the first Jack my calculations always assume there is at least one card before it, and the last Jack one card after. This isn't true, 1 in 13 the first card in the deck would be a Jack and also 1 in 13 time it would be the last.

So I updated my formula to take that into account. Basically I now add 100% to 12 times the probably of losing when you can then divide by 13 to get a mean losing probability

((1+(44/48)*12)/13) * (47/51) * (45/49) * (46/50) * (45/49) * (45/49) * (45/49) * ((1+(44/48)*12)/13) = 0.513874458

[alternatively (576/624) * (47/51) * (45/49) * (46/50) * (45/49) * (45/49) * (45/49) * (576/624)]

That means a 48.6125542% chance of winning.

Thanks guys
EdCollins
EdCollins
  • Threads: 20
  • Posts: 1739
Joined: Oct 21, 2011
February 24th, 2013 at 7:32:59 PM permalink
Quote: estebanrey

That means a 48.6125542% chance of winning.
Thanks guys



No problem, but I still believe it's .48627.
kubikulann
kubikulann
  • Threads: 27
  • Posts: 905
Joined: Jun 28, 2011
February 25th, 2013 at 3:09:01 AM permalink
Hi,
Don has the right answer.

Here is the method:
A.1. Consider a deck of 48 cards (Kings removed). There are 49 places where the four K's can fit. Pick 4 in 49? Yes, but these are combinations WITH replacement, since there can be more than one K in the same interval. So this is G(49;4) possibilities, reformulated as C(52;4).
A.2. We don't want the K's to be neighbouring the J's. Suppose there are X places not neighbouring a J. That makes G(X;4)=C(X+3;4) acceptable possibilities. Probability: C(X+3;4) / C(52;4) .

B. What is X? It depends on the relative positions of the J's in the 48-deck. Fours J's in 45 places with repl. gives G(45;4)=C(48;4). There are five possible configurations.
Config # possibilities X
J-J-J-J C(45;4) 41
JJ-J-J C(45;3) x 342
JJ-JJ C(45;2)43
JJJ-J C(45;2) x 243
JJJJ C(45;1) 44
Total G(45;4) = C(48;4)


C. The formula is
[ C(45;4)C(44;4)+3 C(45;3)C(45;4)+3 C(45;2)C(46;4)+ C(45;1)C(47;4) ] / C(48;4)C(52;4)

= 0.513721

So the probability of any neighbouring J & K is 48.6279%.
Reperiet qui quaesiverit
  • Jump to: