odds of two identical card numbers next to each other in a deck

This is probably a variant of the birthday question, where in any random room of 25 people or so, two will share a birthday.
In a deck of 52 cards, I expect there will be two cards right next to each other that are the same number. Either two 7s next to each other, or two kings, or two 3’s…whatever.

Calculating the odds for this is beyond me though. What are the odds that in a standard deck of 52 cards, that somewhere two adjacent cards will be the same value?

To make it harder, how many random cards do I need to have the odds better than 50% (will 20 random cards give me a 50% chance or greater?).
Finally, the real question. I’d like to turn this into sort of a bar bet. I’d like to wager that X number of random cards will contain two such cards next to each other (with a 90% chance of being successful). What is X?
Bonus if you can explain to me or derive a simple equation where I can predict the probability given any number of random cards

I’m not much help for suggesting a method of calculating this, but the probability of at least one case of adjacent cards having the same denomination has to be really high - I’m guessing 95% or better.

I got started on this but have an error someplace and not sure how to fix it.

There are 52! = 8.1 x 10[sup]67[/sup] permutations of 52 cards. The technical term for that is a “shitload.”

For any given card value, there are 4 cards so there are 4!/2! = 12 ways for the same value of a card in 4 suits to be paired. For each of those 12 ways, there are 51 positions within the deck they could occur. So for 13 values, there are

13 x 12 x 51 = 7,956

For each of those, there are 50! ways to shuffle the other 50 cards in the deck. So for the probability that there will be at least one pair shuffled into the deck, I get

7,956 x 50!/52! =
7,956/(52x51) =
7,956/2,652 = 3

As you see that is >1. I think my error is that any given shuffle with a pair could have an arbitrary number of other pairs, and so my method is counting any given pair more than once.

I’ll run a little Monte Carlo sim on this if I get some time in the morning.

Here’s the table of probabilities. The left column is the number of cards you reveal looking for a sequential pair. The right column is the probability that you’ll find at least one sequential pair.



 cards   probability
   1       0.000
   2       0.059
   3       0.115
   4       0.168
   5       0.218
   6       0.265
   7       0.309
   8       0.350
   9       0.389
  10       0.425
  11       0.460
  12       0.492
  13       0.522
  14       0.550
  15       0.577
  16       0.602
  17       0.626
  18       0.648
  19       0.669
  20       0.688
  21       0.707
  22       0.724
  23       0.740
  24       0.756
  25       0.770
  26       0.784
  27       0.796
  28       0.808
  29       0.820
  30       0.830
  31       0.840
  32       0.850
  33       0.858
  34       0.867
  35       0.874
  36       0.882
  37       0.889
  38       0.895
  39       0.901
  40       0.907
  41       0.912
  42       0.918
  43       0.922
  44       0.927
  45       0.931
  46       0.935
  47       0.939
  48       0.942
  49       0.946
  50       0.949
  51       0.952
  52       0.955


Would you like a graph? Here’s one.

An analytic calculation would be a mess. This was a Monte Carlo calculation. (Uncertainties on the above probabilities vary from 0.00002 to 0.00005, well beyond the precision displayed.)

So, returning to the bar bet…

You have the edge if you use 13 cards or more. You don’t get to 90% until you’re well into the deck (39 cards).

One way to construct the game might be to offer an unnecessarily high number of cards and then haggle down to something at or above 13. So,

YOU: “Hey, I bet you $20 that if I deal out 25 cards, we’ll see two in a row that are the same?”
THEY: “25 cards! No way! Maybe if you did 10…”
YOU: “How about 15? If we don’t see any cards in a row then I give you $20. Else you give me $20.”
THEY: “You’re on, buddy!”
YOU: cha-ching!

But, I guess it depends how risk averse you are. Me, I’ll take any bar-bet-sized wager if I think I have even a tiny edge. If you manage to get a 15-card bet at $20, that’s $3.08 of equity.

I just want to point out that, for once, the Wikipedia article on this math subject is quite good.

The question “What is the expected number of such pairs?” is much easier to answer. :smiley:
The chance any given card among the first 51 cards immediately precedes one of its mates is 3/51, so the expected number of such occurrences is 51 times that, or 3 exactly!

The chance of a given non-match is 48/51, so if these events were independent, OP’s answer would be
p = 1 - (48/51)^51 = .95458…

Of course these events are not independent. Nevertheless, the closeness of .95458… to the Monte Carlo derived answer 0.95452… suggests that the erroneous estimate, in this case, gives a number “close enough for government work.”

I think you’re missing the point. It’s not how many cards you’d have to reveal. It’s how many would he have to have in the deck to have a high chance of winning. If he had 2 cards in the deck, then his odds are 100%, not almost 0%. I assume he’s asking if he should hedge his odds by pulling out the aces and playing with 12 ranks, or maybe pulling all face cards or something.

BTW, OP: Did you see my thread starting “Mathletes:” on the main page? It has a similar question in it.

Not so. What if the 2 cards in your deck are the 4 of clubs and the 10 of hearts?

yes, my intent was not to have an unusual deck with specific cards missing. I wanted to be able to grab the top X number of cards on a normal and randomly mixed deck and claim to be able to find a pair of something within that stack of X cards.

I think the post with the table (and graph!) of the Monte Carlo results is really exactly what I was looking for…assuming it is correct.

Look at the odds for 6 cards (0.265), now look at the odds for 12 cards (0.492). Does this mean if I take 6 cards twice, I have a better chance of a pair than if I take 12 cards? I would have thought they would have been the same.

Maybe the difference is that 6 cards twice requires that I take the 6 cards the first time and return them to the deck and do it again…which is different than taking 12 cards without returning any.

Is this the explanation of the difference in probability?

If you have 2 independent events with probability p1 and p2 and you want to know the probability that at least one of the events occurs you can’t just add the probabilities. After all if you flip 2 coins (p1=p2=0.5) you can’t guarantee 2 heads even though p1+p2=1. This is because if you add the probabilities you are counting the case that they both are true twice. The correct formula is

prob(p1 or p2)=(p1+p2-(p1*p2)).

So in the 6 card case if the events were independent .265+.265-(.265)^2=0.459. A little less than the .492, but this is because if you take 6 cards twice you don’t count the possibility that the last card of your first set matches the first draw of your second set.
**
Back to the OP:**

Pasta’s simulation matches very well with septimus’ formulas. According to my calculations the greatest difference between the two is at 17 cards where is simulation gives 0.626 and the formula gives 0.621.

So I would ignore the slight dependence and just go with 1-(48/51)^n.

Incidentally this is very different from the birthday problem. In that case as you increase the number of people you increase the number of potential matches for a new person added to the group. In your game, each new draw can only match the one previous card. The more analogous situation would be to draw a hand of cards and see if you got a pair.

Bet someone they cannot swallow a teaspoon of ground cinnamon, in 60 seconds, with no water/fluid ingestion. I’ve won drinks a few times with this, offering my $20 against their buying me a drink. They eventually cough out clouds of cinnamon dust.

Why, I never…! :smiley:
You can do the exact calculation for the first few fairly easily. First calculate the probability T(N) that you see no pairs for the first N-1 cards and then you see a pair on the Nth card:

T(1) = 0
T(2) = 3/51
T(3) = 48/51 * 3/50
T(4) = 48/51 * 47/50 * ( 3/50 * 2/49 + 47/50 * 3/49)
. . .

Then, to get the probability that you see a pair at any point up to and including the Nth card, sum the T’s:

P(N) = T(1) + T(2) + . . . + T(N)

So, for instance, P(4) = 0.1683765. My Monte Carlo calculation puts the answer at 0.168, in solid agreement. (Actually, the full answer I get is 0.16834 +/- 0.00004.)

The analytic calculation gets hairly simply because you have to account for how many potential pair-making cards have been chewed up by past draws. It should be a second-order (read: smallish) effect since the chance of getting a pair is high before you have seen many cards, while the chance of your having used up the “winning” card is still low. So, if you deal a K on card 45 without having seen a pair yet, you have to account for the probabilities of having seen 0, 1, 2, or 3 other Ks already, all of which are large. But, it is unlikely that you get to this stage ever anyway, so the impact on doing this wrong in the calculation is mitigated. (For instance, T(45) = 0.0051.)

How are you modeling the shuffling process? The order of cards in an actual shuffled deck isn’t just a random permutation of the original order unless you spend a long time shuffling, and that discrepancy could be a pretty significant source of error.

My simulated shuffle is perfect, which is presumably what the OP wants. If the real-life deck is shuffled by anyone who knows what they’re doing, the shuffle will be indistinguishable from perfect at the precision discussed here.

Besides, what game was previously played with the deck? If it was trick- or series-based (spades, solitaire), then your starting deck has fewer pairs than normal. If it was set-based (rummy), then it has more. If the game doesn’t strongly sort at all (Texas hold’em poker), then the pair occurrences aren’t far from random to begin with. But in all these cases, it isn’t hard to eliminate the ordering with a good shuffle if you know what you’re doing, so why wouldn’t we just assume that’s the game the OP proposes? How about we say it’s scramble/riffle/riffle/riffle/triple-cut/riffle/riffle/riffle/triple-cut/riffle/riffle/riffle/cut? (In a generally unsorted starting deck, like after a session of Texas hold’em, a much simpler sequence would be sufficient to wash away the minor sorting biases introduced by the game, but the above one is plenty good enough and would not leave “a pretty significant source of error”.)