5

What are the odds of shuffling a deck of 52 cards and going through each card one by one without getting any repeats (like 2 kings back to back).

I'm bad at this kind of deduction, but at a high level it seems roughly like 1 in 13 odds over 52 iterations.

Can anyone provide a more accurate approach to solving this?

3 Answers3

3

In short: the odds of having no two consecutive cards with the same rank in a shuffled deck is about 1 out of 22, or 4.5%.

One way to approximate a solution to this problem is to assume that each set of 2 adjacent cards is independent of the other 50 cards:

$$ P\Big(\bigcap_{i=2}^{52} Rank(card_i) \neq Rank(card_{i-1}) \Big) \approx \prod_{i=2}^{52}P\Big(Rank(card_i) \neq Rank(card_{i-1})\Big) = \Big(\frac{48}{51} \Big)^{51} = 0.0454176 $$

This number seems to approximately agree with some of the Monte Carlo simulations done below. Intuitively, I would tend to believe that the total dependence between two cards and the other 50 would be negligibly small, or possibly even zero. I am not sure how to justify this independence assumption, however.

Monte Carlo simulation:

check_deck <-function(deck){
  for(i in 2:52){
    if(deck[i] == deck[i-1]){
      return(0)
    }
  }
  return(1)
}

N = 10000000   # takes a few minutes
count = 0 
for(i in 1:N){
  d = sample(rep(1:13,4))  
  count = count + check_deck(d)
}
p = count/N

Results:

$\qquad \hat{p} = 0.0454795$

95% Confidence interval:

$$\hat{p} \pm 1.96 \sqrt{\frac{1}{N}*\hat{p}(1-\hat{p})} = \big[0.04535,\ 0.04561\big]$$

So we can be 95% sure the true value lies somewhere in the range $[0.04535,\ 0.04561]$. In other words, we can be fairly sure that we can expect about one out of every 22 randomly shuffled decks to have no adjacent cards with the same rank.

David C
  • 131
1

The only way I know of to calculate this would be to brute force it, and it's quite long so I won't go all the way through it, but this should be enough to get your started.

The first card in the deck is guaranteed to not be a repeat. For the second card dealt, there are three cards in the deck which would match the first, and 51 remaining cards, so 3/51 chance. Since we only want to consider the case where it does not match, we will use 48/51 chance of not getting a match.

The third card in the deck can't match the second. Since the first and second cards weren't the same, we know there are 3 cards that do match, so 47/50 chance of not matching.

Now it gets more complicated. For the fourth card, it can't match the third card, but the third and first card could be the same card. It doesn't matter - yet - if the fourth card matches the first or second because that doesn't affect the probability here. It only matters if the first and third card matches because that affects the probability that the third card repeats. The probability that the first and third cards matched is 3/50. So the probability is either 46/49 (third card is not the same as the first) with probability 3/50 or 47/49 with probability 47/50.

So far, the probability that there is not a repeated card for the first four cards is 48/51 * 47*50 * (46/49 * 3/50 + 47/49 * 47/50) or just under 85%, assuming I haven't made any silly math errors.

For the fifth card you must consider the probability that the fourth card matches either the first or second card or neither and combine these probabilities as we did for the fourth card. As you get further into the deck you must consider the different ways this can happen. For instance, you must consider the probability that the previous card matched 1, 2, 3, or 4 times previously. Once you get to the end of the deck you will have the value you are looking for.

Michael
  • 351
  • I wrote a script to try this experiment over thousands of iterations, the value appears to be around 4.5%, but I'll try your way (or writing a script to do it your way) to see if that results in a similar number. –  Sep 08 '16 at 17:47
  • But with this that the last three cards would be negative. If you have not yet hit then there is a higher chance brother is still around. If you are just looking a few hand you could look at it that way but not the whole deck. – paparazzo Sep 08 '16 at 19:20
  • @Paparazzi Not sure I follow you. You may have to work backwards from the last card to make sure you account for cases such as where the last card is forced to be the same as the next to last, due to it being the only card left, but subtracting those out won't make the probability negative. – Michael Sep 08 '16 at 19:37
  • Pretty simple. If the probability of any card matching to prior is zero or less then the algorithm is wrong. – paparazzo Sep 08 '16 at 19:43
  • 1
    Some of the numbers seem a bit mixed-up in the example calculations. But based on the principles of this answer, the probability that the first two consecutive cards of the same rank are the $n$th card dealt and the one after it is $p_0(m-1)/m+p_1(m-2)/m+p_2(m-3)/m$ where $m=52-n$ and $p_0,p_1,p_2$ are (respectively) the probabilities that cards of the same rank as the $n$th card occurred $0,1,$ or $2$ times in the first $n-2$ cards. This will never be less than zero. @Paparazzi If you get less than zero you have implemented a different algorithm. – David K Sep 14 '16 at 18:46
0

Using combination

combin(52, 2) = 1326
combin(4, 2) = 6
6*13/1326 = 0.058823529
1 - ((1 - 0.058823529) to the power of 26) = 0.793249012

But this is hands. This would miss the matches between hands.

paparazzo
  • 330