1
$\begingroup$

Problem

In a gin variant, you win immediately if you are dealt a hand with no sets (3+ of a kind or suited run of 3+ cards) and no "potential sets", i.e. no additional card added to the hand could make a set. What's the probability of this happening for a hand of $n$ cards? I actually play this game ($n=9$) and my friend and I were curious about this probability, which is the motivation for this question. It's easy to compute numerically for any $n$ and some special $n$ values are also easy (e.g. $n$=1, $n>13$) but an analytic solution for general $n$ seems deceptively difficult.

(Bad) Approach Idea

I cannot seem to find a nice way to do it analytically at all. Obviously we want the total number of ways to make this special hand, $N_h$, divided by $N={52 \choose n}$ possible hands.

The no 3+-of-a-kind/potential 3+-of-a-kind requirement is simple enough because a potential 3-of-a-kind is just a pair. This means we must select $n$ distinct values from the $13$ values in the deck $\to {13 \choose n}$.

However the suited runs are much more difficult. Depending on the distribution of the $n$ values across the $4$ suits, the number of ways of making runs/potential runs vary. The only thing I can think of is to enumerate the probabilities of runs/potential runs for each number of cards in a suit. E.g. $1$ card in a suit never makes a run/potential run. $2$ cards has $n-m+1$, $m$ card runs and $n-2$ "gapped" potential runs. $n=3$ then is more complicated with the placement of the $3$rd relative to the other $2$. There are also complications with double counting since these things are not mutually exclusive. I have some vague notions that these enumerations have some relationship to the polyhedral numbers but haven't pursued that in depth because I'm convinced there's a better approach and I'm hoping someone here can help me find it!

Numerics

It's easy to write a program to do this numerically for some $n$. Just check that there are no pairs and that within a suit all cards are at least $2$ away from every other card. Here's a quick Mathematica code that does it

deal[n_] := QuotientRemainder[RandomSample[Range[0, 51], n], 13]
valid[hand_] := DuplicateFreeQ[Transpose[hand][[-1]]] &&
    Min[GroupBy[hand,First,Min[Abs[Differences/@Subsets[Last/@#,{2}]]]&]]>2
prob[n_, num_] := N@Count[Table[valid[deal[n]], {i, num}], True]/num

For the game I play $n=9$ and dealing half a billion hands gives $P\approx 0.00185276$

$\endgroup$

1 Answer 1

1
$\begingroup$

Consider the sequence of $n$ distinct ranks in a hand without potential suited runs. Let $j$ be the number of groups of ranks separated by gaps of length at least $2$. Let $k$ be the number of contiguous runs of ranks. And let $m$ be the number of contiguous runs of ranks of length at least $2$.

Consider the number of suit options for each rank, starting from the highest. The first rank can have all $4$ suits, and any rank following a gap of length at least $2$ can also have all $4$ suits, so there are $j$ ranks that can have all $4$ suits. Other ranks can usually have one of $3$ suits, unless they’re in the third or later position of a run of contiguous ranks, in which case they can have only one of $2$ suits. So there are $j$ ranks with $4$ options, $k+m-j$ ranks with $3$ options and $n-(k+m)$ ranks with $2$ options. The positions of the $m$ runs of length at least $2$ can be chosen among the $k$ runs in $\binom km$ ways. The $n-(k+m)$ extra ranks (the ones with $2$ options) can be distributed over the $m$ runs of length at least $2$ in $\binom{n-(k+m)+m-1}{m-1}=\binom{n-k-1}{m-1}$ ways. There are $\binom{k-1}{j-1}$ ways to choose the $j-1$ long gaps among the $k-1$ gaps. And the $13-n-(k-1)-(j-1)$ ranks that are not selected and not yet accounted for in the gaps can be distributed over $j+1$ slots in $\binom{13-n-(k-1)-(j-1)+j}j=\binom{15-n-k}j$ ways. Thus in total there are

$$ \sum_{k=1}^{\min(n,15-n)}\sum_{m=0}^{n-k}\sum_{j=1}^k\binom km\binom{n-k-1}{m-1}\binom{k-1}{j-1}\binom{15-n-k}j4^j3^{k+m-j}2^{n-(k+m)} $$

hands without potential suited runs. Here’s code to evaluate this in Sage:

j,k,m,n=var('j,k,m,n')
def binom(n,k):
    return 1 if n == -1 and k == -1 else binomial(n,k);
sum(binomial (k,m) * binom (n-k-1,m-1) * binomial (k-1,j-1) * binomial (15-n-k,j) * 4**j * 3**(k+m-j) * 2**(n-(k+m)) for k in range(1,min(n+1,16-n)) for j in range (1,n+1) for m in range(0,n-k+1))

(Note that the case $m=0$ and thus $k=n$ is treated correctly, since for this case $\binom{-1}{-1}=1$, but this is not correctly implemented in Sage; hence the custom function binom.)

For $n=9$ the result is $6820068$, so the probability to draw such a hand is

$$ \frac{6820068}{\binom{52}9}=\frac{1705017}{919768850}\approx0.0018537\;, $$

in good agreement with your numerical result (which you stated with excess precision, as its standard deviation is $\sqrt{\frac{p(1-p)}n}\approx2\cdot10^{-6}$).

$\endgroup$
6
  • $\begingroup$ Very nice! I assume it's unlikely that expression can be simplified? I tried getting Mathematica to do it but gave up as it was hogging all my resources. I might doodle a bit with pen, paper and a bunch of factorials. I do note that the bound on the outer sum, $\min(n,15-n)$, seems unnecessary as just using $15-n$ gives me the same result which is nice. $\endgroup$
    – bRost03
    Commented Apr 15, 2020 at 15:48
  • $\begingroup$ @bRost03: Yes, I doubt that it can be simplified. $k$ appears in all four binomial coefficients, so that looks rather hopeless, and the other two sums yield hypergeometric series (here's a Wolfram|Alpha calculation). About the upper limit for $k$: You're right, technically speaking, since for $k\gt n$ the upper limit for $m$ becomes negative so the second sum becomes empty; but there's also something to be said for avoiding that by limiting $k$ :-) $\endgroup$
    – joriki
    Commented Apr 15, 2020 at 19:16
  • $\begingroup$ I think you're right on all counts. I was able to get it down to a single sum $$\sum _{k=1}^{\min (n,15-n)} \left(\frac{2}{3}\right)^{1-k} \left(-2 (-1)^k (2 k-15) \, _2F_1\left(1-k,2 (k-7);2;\frac{4}{3}\right) \delta _{k,n}-3 k 2^n (k+n-15) \, _2F_1\left(1-k,k+n-14;2;\frac{4}{3}\right) \, _2F_1\left(1-k,k-n+1;2;\frac{3}{2}\right)\right)$$ and I think further simplification may be possible because there's a $\infty\cdot 0$ issue when $n=k$ which Mathematica doesn't handle carefully (hence the $ \delta_{k,n}$ correction term I added by hand). Thanks so much for the answer! $\endgroup$
    – bRost03
    Commented Apr 16, 2020 at 3:52
  • $\begingroup$ @bRost03: You're welcome! Strange that Mathematica doesn't handle the $n=k$ case properly – as I noted in the answer, one of the binomial coefficients is $\binom{-1}{-1}=1$ in this case, and Sage treats this as $0$ instead, but Wolfram|Alpha (which is pretty much Mathematica) does return $-1$ if you ask it just about that coefficient. $\endgroup$
    – joriki
    Commented Apr 16, 2020 at 4:44
  • $\begingroup$ Yeah the issue is related to that, see (wolframalpha.com/input/?i=%7B-1+choose+-1%2C+n+choose+-1%7D). It assumes that $\binom{n}{-1}$ is 0 but that's not true when $n=-1$ so when doing things analytically it prematurely cancels this term. Kind of disappointing but probably not worth going down that rabbit hole to try to fix it! $\endgroup$
    – bRost03
    Commented Apr 16, 2020 at 6:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .