6

I read about a magic trick yesterday that relied on probability - I gave it a try a few times and it seemed to work, but I was wondering what the actual probability of success is. I understand basic probability but I'm not quite sure how I would calculate this.

The basic premise stands as follows: choose two distinct card ranks (without a suit) e.g. king and a 7 (but you cannot choose both the same). Shuffle the cards and now fan them out. There should be a king and a 7 adjacent to each other in the pack, just based on probabilities.

My question is what are the chances of success here? Or how do you calculate it?

  • 1
    how many cards does the deck have? – azimut Jul 31 '13 at 12:40
  • @azimut You can assume a standard 52 card deck (so just exclude jokers) –  Jul 31 '13 at 12:45
  • OVER 65%......I dont know the precise answer but I know its over 65%. I know this because otherwise people wouldnt use it as a scam to win beers if it was much less. It works at least 2 times out of 3. If you think that the 1st card you choose (if its not at either end) has 8 chances to have the 2nd card next to it, because the 2nd card could be before or after the 1st card on each of the 4 occasions. Similarly,the 2nd card also has 8 chances. Its obviously is not as simple that, but once you look at it like that it shows you that the odds are high. Just try it a few times and youll know its w –  Nov 30 '13 at 05:57
  • ell over 65%.${}$ – Michael Greinecker Nov 30 '13 at 07:16

6 Answers6

4

Short answer: The chance that there are no 7s adjacent to a king is $${\sum_{m=0}^3 \sum_{n=0}^4 {3\choose m} {5-m\choose n} {44+m\choose 4-m-n}{40+2m+n\choose 4}\over {52\choose 4}{48 \choose 4}} = {300684703\over 585307450}\approx .513721.$$


Long answer: Choose four indices when the kings will go: $1\leq k_1<k_2<k_3<k_4\leq 52$; there are $52\choose 4$ ways to do this.

For a set $\{k_1,k_2,k_3,k_4\}$, there are generally eight adjacent spots, one on each side of each $k_j$. However, we can lose a spot if $k_1=1$, or $k_4=52$, or if a pair of $k$-values has only one spot between them. We can even lose two spots if there are consecutive $k$ values. Within $\{k_1,k_2,k_3,k_4\}$, define $n$ to be the number of single spots lost, and $m$ to be the number of double spots lost. The value $m$ runs from 0 to 3, while $n$ runs from 0 to 4, and there are $8-(2m+n)$ spots adjacent to a $k$ value in this set.

We also define the "gaps" between the $k$-values as $$g_1=k_1-1, g_2=k_2-k_1-1, g_3=k_3-k_2-1, g_4=k_4-k_3-1, g_5=52-k_4.$$ Notice that $g_1+g_2+g_3+g_4+g_5=48$ for every set of 4 indices.

We now count the number of sets of $k$-values with a fixed $m$ and $n$ value, via their $g$-values. We will divide the set $\{g_1,g_2,g_3,g_4,g_5\}$ into three parts.

  1. First choose $m$ of $g_2,g_3,$ and $g_4$ to be equal to zero. There are $3\choose m$ ways to do this.
  2. Now choose $n$ of the remaining $5-m$ gaps so that $$n=1_{[g_1=0]}+1_{[g_2=1]}+1_{[g_3=1]}+1_{[g_4=1]}+1_{[g_5=0]}.$$ There are ${5-m\choose n}$ ways to do this.
  3. Consider the equation $$g_1+(g_2-1)+(g_3-1)+(g_4-1)+g_5=45. \tag 1$$ The $n$ gaps contribute zero to the left hand side of (1), while each of the $m$ gaps contributes $-1$.

Therefore the remaining $5-m-n$ free values on the left hand side of (1) are positive integers that add to $45+m$, so by "stars and bars" there are $44+m\choose 4-m-n$ ways to choose those values.

To summarize, the number of sets $\{k_1,k_2,k_3,k_4\}$ with values $m$ and $n$ is $${3\choose m} {5-m\choose n} {44+m\choose 4-m-n}.$$

Finally, let's choose indices for the four 7s. There are $48\choose 4$ ways that we can choose them, but there are only $40+2m+n\choose 4$ ways to choose them so that none is adjacent to a king. Here $40+2m+n=48-(8-(2m+n))$ is the number of indices not at or adjacent to a king's index.

Putting it all together, the chance that there are no sevens adjacent to a king is $${\sum_{m=0}^3 \sum_{n=0}^4 {3\choose m} {5-m\choose n} {44+m\choose 4-m-n}{40+2m+n\choose 4}\over {52\choose 4}{48 \choose 4}} = {300684703\over 585307450}\approx .513721.$$

2

This can be calculated precisely using the theorem of total probability. There are 8 mutually exclusive conditioning cases: 8 spaces next to 4 kings (the kings sufficiently well spread out in the pack), down to only 1 space next to 4 kings (all 4 kings at one side or the other). Clearly the more spaces you have, the more chance there is of one of the spaces being occupied by a 7. So an upper bound on the probability is given by the probability of getting at least one 7 in one of the 8 spaces, which is $1 -$ the probability of getting no 7s in any one of the 8 spaces.

$$\begin{eqnarray*} 1 - \rm{Pr}(\mbox{no 7s in 8 spaces}) &=& 1 - \frac{44}{48}\frac{43}{47}\frac{42}{46}\frac{41}{45}\frac{40}{44}\frac{39}{43}\frac{38}{42}\frac{37}{41} \\ &=& 1 - \frac{40 \times 39 \times 38 \times 37}{48 \times 47\times 46\times 45} \\ &=& 0.53 \end{eqnarray*}$$

which isn't as high as the question suggests.

Edit: It's possible to calculate the probability programmatically, by running through all the $\frac{52!}{4!4!44!}$ = 52677670500 possible permutations. Using the following C++ program, which took an hour or two to run, the probability comes to 0.486279. I would prefer it if there were a more elegant way of computing the probability however!

#include <stdio.h>
#include <algorithm>
#include <math.h>

int main(int argc, char* argv[])
{
    const int n = 52;
    int x[52] = {
        0,0,0,0,
        1,1,1,1,
        3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3};
    double count = 0;
    double total = 0;
    double lastFreqPrinted = 0;
    do {
        total++;
        for(int i=1; i<n; ++i) {
            if ((x[i-1] + x[i]) == 1) {
                count++;
                double freq = count/total;
                if (fabs(lastFreqPrinted - freq) > 0.0001) {
                    printf("%.4f out of %.0f\n", freq, total);
                    lastFreqPrinted = freq;
                }
                break;
            }
        }
    } while (std::next_permutation(x,x+n));
    printf("%f out of %.0f\n", count/total, total);
    return 0;
}
TooTone
  • 6,343
  • @azimut thanks, I may have missed something but I can't quite see it. I was thinking along the following lines: 8 slots altogether next to the 4 kings, and because we have used 4 kings so we have 48 cards left. For the first slot, 44 out of the remaining 48 cards aren't a 7, for the second slot, 43 out of the remaining 47 cards aren't a 7, and so on. – TooTone Jul 31 '13 at 15:45
  • @azimut: I'm interested to know how you get a 80% - this is quite different to 53% - but feels more like what I've experienced trying it. –  Aug 01 '13 at 08:03
  • @Ian How did you try it? As an alternative to counting all the different permutations, I tried simulating it in R. I used the following code to set up the cards, with 1...4 for 7s and 101...104 for kings: cards=c(1,2,3,4, 101,102,103,104, 1001:1044). Then a simulation is simply: n=100000;sum(lapply(1:n,function(i) {d=abs(diff(sample(cards,52))); sum(50<d & d<150)}) > 0)/n. This gave me numbers in the region of 0.485 to 0.488. Like I said in my answer, I would be v interested in an analytic solution to calculate the probability! – TooTone Aug 01 '13 at 08:52
  • The computed values suggest that my previous argument was flawed...Seems that for some reason I tried to place eight 7's instead of four. My (corrected) argument is: Fix the positions of the kings, such that there are 8 neighboring positions. Now for the first seven, 40 out of 48 positions are good. For the second seven, 39 out of 47 are good, for the third 38 out of 46 and for the fourth 37 out of 45. This results in the same value as in the +1 answer of TooTone. – azimut Aug 01 '13 at 10:56
  • 53% is quite high, in my opinion :) – user132181 Mar 19 '14 at 15:48
  • 1
    @TooTone: I have provided another analytical answer, albeit almost a decade later ! Hope you enjoy it !$;;:)$ – true blue anil Dec 15 '22 at 16:06
1

4 (Queens) x 4 (Kings) x 2 (swap QK order) x 51 (places in the deck) x 50! (rest of cards) / 52! (every possible deck)

=0.6153846154

Does this even make sense? It's been a long time since I've done any probabilities.

Vince
  • 11
  • Welcome to MathSE. Your answer looks promising. Please expand on your reasoning and see this page on how to better format your mathematics for this site. – Mike Pierce Mar 25 '15 at 18:50
1

Inspired by the exact answer of the elusive User $940$, I decided to try a different tack to obtain the same answer

Considering the Kings and $7's$ arranged amongst themselves, there are $\frac{8!}{2!2!} = 70$ permutations. Using symmetry, for the $35$ reversible patterns, we can find the minimum number of spacers needed to keep just the Kings and $7's$ apart as

\begin{array}{| c | c | c | c | c | c | c | c | c|}\hline \\Spacers &1 &2 &3 &4 &5 &6 &7 \\ \hline Cases & 1 & 3 & 9 & 9 & 9 & 3 & 1\\ \hline \end{array}

We can now view it as a stars and bars problem with $52$ minus preplaced spacers as stars and the $8$ (kings plus $7's$) as bars, and compute the probability that no two Kings and $7's$ are adjacent as

$$\frac{\binom{51}8+3\binom{50}8 + 9\binom{49}8 + 9\binom{48}8 + 9\binom{47}8 +3\binom{46}8 +\binom{45}8}{35\binom{52}8}$$

$$= \frac{300684703}{585307450},\approx 0.513721$$

0

A very rough estimation (it does not consider the fact that in your example a king may be the first or last card, and that there may be two consecutive kings) is that there are four kings, each of which has two neighboroughs: so the probability there is no 7 near a king is $1 -(\frac{12}{13})^8 \approx .473$... I thought it would be higher.

The kings are accounted for, so (in this approximation) it should be $1 -(\frac{11}{12})^8 \approx 0.5015$. Better is to account for the fact that you have used up some of the non-sevens, so $1-\frac{44\cdot 43\cdot 42\dots 37}{48\cdot 47 \cdot 46 \dots 41}=1-\frac {44!40!}{48!36!}\approx 0.5303$

Ross Millikan
  • 374,822
mau
  • 9,774
0

I just hacked together a Monte Carlo simulation. After 100.000.000 tries, the average success rate of your "trick" is 48.625%, which is quite close to the value in the answer of TonToe.

When using a smaller 32 card deck instead, the success rate increases to about 68%.

azimut
  • 22,696