# Is there an easy statistical formula for this?

**URL:** <https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248>\
**Category:** Factual Questions\
**Created:** [June 26, 2006, 7:14pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248 "2006-06-26T19:14:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Earl\_Snake-Hips\_Tucker](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/earl_snake-hips_tucker/32/3269_2.png) [@Earl\_Snake-Hips\_Tucker](https://boards.straightdope.com/u/Earl_Snake-Hips_Tucker)\
**Post date:** [June 26, 2006, 7:14pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/1 "2006-06-26T19:14:51Z")

</div>

And, no, it most definitely ain’t homework.

Let’s say you have X number of cards in some order, and you thoroughly shuffle them.

What are the odds that at least one is in its same position as before the shuffle?

---

<div class="post-metadata">

**Author:** ![treis](https://avatars.discourse-cdn.com/v4/letter/t/bc79bd/32.png) [@treis](https://boards.straightdope.com/u/treis)\
**Post date:** [June 26, 2006, 7:36pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/2 "2006-06-26T19:36:42Z")

</div>

[QUOTE=Earl Snake-Hips Tucker]  
And, no, it most definitely ain’t homework.

Let’s say you have X number of cards in some order, and you thoroughly shuffle them.

What are the odds that at least one is in its same position as before the shuffle?  
[/QUOTE]

Assuming that the cards and randomized there is a 1/52 chance of the card being in the same place, or a 51/52 that it is in a different place. You want to know what the odds are that one is in the same space, but it’s easier to calculate the odds that one won’t and subtract that from one. The odds that one card is not in the same spot is 51/52, for 52 cards it’s (51/52)[sup]52[/sup]. That comes out to 36.4%. That means there is a 63.6% chance that at least one card will be in the same spot.

---

<div class="post-metadata">

**Author:** ![muttrox](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@muttrox](https://boards.straightdope.com/u/muttrox)\
**Post date:** [June 26, 2006, 7:40pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/3 "2006-06-26T19:40:09Z")

</div>

My first instinct was the answer is 1 - [(1-1/x)^x]. This is line with the “lost key” problem" at [Probability - FAQ - Wizard of Odds](http://wizardofodds.com/askthewizard/probability.html).

However, it is unclear to me whether that means two keys can get the same code… that is, is this invalid because two cards can’t land in the same slot. I also note that my formula predicts a 75% change with two cards, when the answer is clearly 100%. So I guess I’m saying I’m wrong and don’t know either! But I have a suspicion that my answer gets closer to the truth as x goes up.

---

<div class="post-metadata">

**Author:** ![muttrox](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@muttrox](https://boards.straightdope.com/u/muttrox)\
**Post date:** [June 26, 2006, 7:48pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/4 "2006-06-26T19:48:07Z")

</div>

…the answer is clearly 50% I mean. Good to see that treis is on the same wavelength as me.

---

<div class="post-metadata">

**Author:** ![Omphaloskeptic](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@Omphaloskeptic](https://boards.straightdope.com/u/Omphaloskeptic)\
**Post date:** [June 26, 2006, 8:05pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/5 "2006-06-26T20:05:40Z")

</div>

The term to help you Google is “derangement.” (Specifically, you’re looking for the probability that the order is _not_ a derangement.) [Here](http://boards.straightdope.com/sdmb/showthread.php?t=331673)’s a previous thread, containing a MathWorld link.

The answer differs from the ((X-1)/X)[sup]X[/sup] posted above, because the card positions are not independent (as **muttrox** noticed in the case X=2); in the limit of large X this probability tends to the same result, however.

---

<div class="post-metadata">

**Author:** ![borschevsky](https://avatars.discourse-cdn.com/v4/letter/b/97f17d/32.png) [@borschevsky](https://boards.straightdope.com/u/borschevsky)\
**Post date:** [June 26, 2006, 8:07pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/6 "2006-06-26T20:07:05Z")

</div>

This kind of shuffling is called a [derangement](http://en.wikipedia.org/wiki/Derangement). As the number of cards goes to infinity, the probability goes to 1/e =~ 36.8%.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [June 26, 2006, 8:08pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/7 "2006-06-26T20:08:24Z")

</div>

I don’t recall the chance for “at least one”, but I do recall that, for any number of cards, the expected number of cards in the same position is exactly 1.

---

<div class="post-metadata">

**Author:** ![wolf\_meister](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/wolf_meister/32/15202_2.png) [@wolf\_meister](https://boards.straightdope.com/u/wolf_meister)\
**Post date:** [June 26, 2006, 8:29pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/8 "2006-06-26T20:29:23Z")

</div>

Among other things I have seen this stated as the drunken sailor probability problem.

A bunch of sailors all get “smashed” while on shore leave. They return to their ship and randomly choose to sleep in whatever bed they find. What are the odds that each sailor is in the _wrong_ bed? As the number of sailors gets larger, the limit is 1/e or about .3678794412. So the probability of at least 1 sailor being in the correct bed is 0.6321205588 or 63.21205588%.

(I have also seen this stated as the secretary and the envelopes problem, whereby letters are inserted randomly into envelopes).

So, it seems I’m in agreement with **treis,**  **Omphaloskeptic** and **borschevsky**.

---

<div class="post-metadata">

**Author:** ![Earl\_Snake-Hips\_Tucker](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/earl_snake-hips_tucker/32/3269_2.png) [@Earl\_Snake-Hips\_Tucker](https://boards.straightdope.com/u/Earl_Snake-Hips_Tucker)\
**Post date:** [June 26, 2006, 9:07pm UTC](https://boards.straightdope.com/t/is-there-an-easy-statistical-formula-for-this/362248/9 "2006-06-26T21:07:13Z")

</div>

Many thanks, all.
