The negative hypergeometric distribution isn’t labeled negative because it uses negative numbers. It’s negative because we’re thinking about failure…

The Hypergeometric Flower Pot

Ursula Whitcher
Mathematical Reviews (AMS)

I spent the hottest days of summer engrossed by Balatro, a video game cross between poker and solitaire that’s catnip for probability fans. The goal is to build high-scoring poker hands. Unlike traditional poker, in Balatro the best hand changes depending on which jokers you buy: certain jokers can add constants to your score, or even multiply it.

New Balatro players often chase classic good poker hands, such as four of a kind or the straight flush. As a mathematician, I knew better: my initial strategy was to multiply my score by as many numbers $n>1$ as possible.

One handy source of Balatro multipliers is the Flower Pot joker. The Flower Pot triples your score if you play one card from each of the four suits. In the baseline Balatro game, the Flower Pot only triggers when these four cards are part of a legal poker hand (such as the elusive four of a kind). But you can improve your odds by using the Splash joker, which allows you to score any combination of one to five cards.

Drawing of a heart, spade, diamond, and club as flowers emerging from a flowerpot

How hard is it to draw cards of all four different suits? There are different ways to make this question mathematically precise. For instance, if we know the composition of our deck, we could ask:

Flower Pot Splash Problem. How many cards should you expect to draw in order to find a card of each suit?

(A Balatro player might add, “How does this number compare to the size of a typical Balatro hand?”)

The answer to the Flower Pot Splash Problem has an unexpected connection to one of my favorite infinite series—the hypergeometric series.

Diamonds and Queens

Before we delve too far into infinity, let’s work on the solution to the probability problem. To keep things simple, we’ll assume we have a standard deck of 52 playing cards, with 13 cards of each suit.

We’ll start with an easier problem.

Eight cards laid out on a table, of which five are diamonds

Unique Diamond Flush Problem. Suppose we draw a hand of 8 cards. What’s the probability that our hand contains exactly 5 diamonds?

There are \({52 \choose 8}\) ways to draw a hand of 8 cards from the standard deck. (We’re using the binomial coefficient here: ${52 \choose 8} = \frac{52!}{8!(52-8)!}$.) Out of all these possibilities, we want a hand that contains 5 diamonds and 3 cards that are not diamonds. There are \({13 \choose 5}\) ways to choose 5 diamonds out of the 13 total diamonds in the deck, and there are \({{52-13} \choose {8-5}}\) ways to choose 3 non-diamonds out of the total 39 non-diamonds in the deck. Multiplying, we count \({13 \choose 5}{{52-13} \choose {8-5}}\) ways to choose exactly 5 diamonds.

Thus, the probability of an 8-card hand containing exactly 5 diamonds is:

\[ \frac{{13 \choose 5}{{52-13} \choose {8-5}}}{{52 \choose 8}} = \frac{1287 \cdot 9139}{752,538,150} \approx
0.0156,\]

or between 1 and 2 percent.

More generally, if we have a deck of $N$ cards containing $K$ special cards and we draw a hand of size $n$ without replacing our reshuffling, the probability of finding exactly $k$ special cards is

\[ \frac{{K\choose k}{{N-k}\choose {n-k}}}{N \choose n}.\]

We say a random variable $X$ whose chance of success is given by this formula follows the hypergeometric distribution.

Instead of drawing a hand of a fixed size, what if we kept drawing until we found the cards we were looking for? Here’s an example problem of this sort.

A hand of cards including two queens

Best Friends Problem. Suppose we keep drawing cards until we find a pair of queens. What’s the probability that we will end up drawing exactly 8 cards?

In order for this to happen, we need to draw exactly one queen in the first 7 cards, and then draw a second queen as the 8th card. There are four queens in a standard deck, so if we haven’t made any funny adjustments, the probability of drawing one queen in 7 cards is given by the hypergeometric distribution with $n=7$, $K=4$, and $k=1$. At that point, the remaining deck will have $52-7$ cards of which 3 are queens. Thus, the solution to the Best Friends Problem is:

\[\frac{{4\choose 1}{{52-1}\choose {7-1}}}{52 \choose 7}\cdot \frac{3}{52-7} \approx 0.0359,\]

or between 3 and 4 percent.

In general, if we have a deck of $N$ cards containing $K$ special cards and we want to know the probability that we will locate $k$ of the special cards in exactly $m$ draws, the formula is

\[ \frac{{{K}\choose{k-1}}{{N-(k-1)} \choose {m-(k-1)}}}{{N}\choose{m-1}} \cdot \frac{K-k+1}{N-m+1}.\]

This simplifies to:

\[ \frac{{{m-1}\choose{k-1}}{{N-m}\choose{K-k}}}{N \choose K}. \]

We say a random variable $Y$ whose chance of success is given by this formula follows the negative hypergeometric distribution.

The negative hypergeometric distribution isn’t labeled negative because it uses negative numbers. It’s negative because we’re thinking about failure: in order to find $k$ special cards in exactly $m$ draws, we have to fail to find $k$ special cards in the preceding $m-1$ draws.

We’ll need one fact about the negative hypergeometric distribution: its expected value is $\frac{N+1}{K+1} \cdot k$. For example, if we’re looking for a pair of queens in a standard deck of playing cards, we’d expect to draw $\frac{52+1}{4+1} \cdot 2 = 21.2$ times: we expect to go through a little bit less than half the deck.

Flower Pot Splash

Now we’re ready for the solution to the Flower Pot Splash Problem! There’s a nice explanation of the solution by Marcus Nye on math.stackexchange.com, which we’ll follow here. The idea is to break down the problem of finding cards of four distinct suits into four different problems: finding the first suit, finding the second suit, finding the third suit once we’ve found cards of the first two suits, and finally finding the fourth suit given cards of the first three suits.

Our initial draw always pulls a card of some suit, so the expected number of draws to find the first suit is 1.

After we’ve drawn our first card, we have $3 \cdot 13$ cards of the remaining suits in a deck of 51 cards. We want to know the expected time to find 1 of these cards, so that’s the expected value of the negative hypergeometric distribution with $N = 51$, $K=39$, and $k=1$. Thus, the expected number of draws to find the second suit is $\frac{51+1}{39+1} = \frac{13}{10}$.

Now we have 26 cards of the 2 remaining suits. We can use the negative hypergeometric distribution again, this time with $K=26$. How many cards do we expect remain in the deck? Well, we expect there will be $51-\frac{13}{10}$ cards left. Plugging back into the expected value formula for the negative hypergeometric distribution, we conclude we should expect $\frac{169}{90}$ draws to find the third suit.

We use a similar logic to find the expected number of draws for the fourth suit. There are $13$ cards of the final suit and we expect $51-\frac{13}{10}-\frac{169}{90}$ cards remain in the deck, so the negative hypergeometric distribution tells us to expect $\frac{2197}{630}$ more draws.

In all, we expect to draw $1+\frac{13}{10}+\frac{169}{90}+\frac{2197}{630}$ in order to find a card of each suit. That works out to approximately $7.665$ cards. With 8 cards in a standard Balatro hand, Flower Pot Splash multipliers should come rolling in!

Eight cards laid out on a table. There are cards of every suit; a single heart is in the lower right-hand corner.

Hypergeometric Series

We’ve seen why the negative hypergeometric distribution is labeled negative. But what makes the hypergeometric distribution hypergeometric? As I noted earlier, it’s related to an infinite series called the hypergeometric series.

Before we define the hypergeometric series, let’s contemplate two other beloved series. The exponential series is given by $\mathrm{exp}(z) = \sum_0^\infty \frac{z^k}{k!}$, and the geometric series is given by $g(z) = \sum_0^\infty z^k = 1 + z + z^2 + \dots$.

If we differentiate the exponential series term by term, we get the same series back again: $\frac{d}{dz} \mathrm{exp}(z) = \mathrm{exp}(z)$. If we differentiate the geometric series, we pick up leading constants: $\frac{d}{dz} g(z) = \sum_0^\infty (k+1) z^k = 1 + 2 z + 3 z^2 + \dots$ Taking another derivative, we see products of constants: $\frac{d^2}{dz^2} g(z) = \sum_0^\infty (k+1)(k+2) z^k = 2 + 2\cdot 3 z + 3 \cdot 4 z^2 +\dots$

The coefficients that appear in derivatives of the geometric series look like part of a factorial. Similar expressions show up when we’re simplifying binomial coefficients $n \choose k$. We can represent them using the Pochhammer symbol notation (named after the late nineteenth- and early twentieth century German mathematician Leo August Pochhammer):

\[(a)_n = a (a+1) \cdots (a+n-1).\]

The notation is chosen so that $(a)_n$ has $n$ terms. Since $(1)_n = n!$, we make the convention that $(1)_0 = 0! = 1$, and more generally $(a)_0 = 1$ for any $a$.

With the Pochhammer symbol in our pockets, we can see that the exponential series, the geometric series, and derivatives of the geometric series all have something in common: in each case, $z^k$ is multiplied or divided by a Pochhammer symbol.

The hypergeometric series is an infinite series whose coefficients are ratios of Pochhammer symbols of length $k$. Formally, let $a_1, \dots, a_m$ be numerator parameters and $b_1, \dots, b_n$ be denominator parameters. We’ll assume none of the $b_j$ are zero or a negative integer, to avoid dividing by zero later. We define:

\[{}_m F_n(a_1, \dots, a_m; b_1, \dots, b_m \mid z) = \sum_0^\infty \frac{(a_1)_k \cdots (a_m)_k}{(b_1)_k \cdots (b_n)_k} \frac{z^k}{k!}\]

For example, ${}_1 F_1(1; 1 \mid z) = \frac{k!}{k!} \frac{z^k}{k!} = \sum_0^\infty \frac{z^k}{k!}$, the exponential series. Similarly, ${}_2 F_1(1, 1; 1 \mid z)$ yields the geometric series $g(z)$.

(One note on terminology: some people refer to the hypergeometric series we’ve just defined as the generalized hypergeometric series, and reserve the term hypergeometric series for series of the form ${}_2 F_1$. We’ll use the more expansive language here.)

You can check that the term-by-term derivative $\frac{d}{dz} g(z)$ can be written as ${}_2 F_1(2, 2; 2 \mid z)$. Here’s the general formula for the $r$th derivative of a hypergeometric series:

\[\begin{multline*}
\frac{d^r}{dx^r} {}_m F_n(a_1, \dots, a_m; b_1, \dots, b_m \mid z) = \\
\frac{(a_1)_r \cdots (a_m)_r}{(b_1)_r \cdots (b_n)_r} {}_m F_n(a_1+r, \dots, a_m+r; b_1+r, \dots, b_m+r \mid z).
\end{multline*}\]

The derivative of a hypergeometric series is the product of another hypergeometric series and a constant—and that constant is itself a ratio of Pochhammer symbols!

Hypergeometric series turn up all over the place. Indeed, any power series $\sum_0^\infty a_k z^k$ such that the ratio $a_{k+1}/a_k$ can be written as a rational function $p(k)/q(k)$ is a hypergeometric series. (Here $p(k)$ and $q(k)$ are polynomials.)

The functions defined by convergent hypergeometric series are similarly pervasive! I personally first encountered them in the context of theoretical physics, while learning about mirror symmetry.

Hypergeometric series are even the subject of a book-length geometric love letter. In the introduction to his textbook Hypergeometric Functions, My Love, Masaaki Yoshida writes:

You might ask why this story attracts me so much. Before answering
this, may I pose a question to you? Can you give a logical answer to the
question of why your friend (wife, husband or some such person) attracts
you so much? Your answer may be “I just like her/him.” My answer is
similar, but if you insist that I explain further, I (a man) would add “she
has many nice friends, who make my life more enjoyable.”

Hypergeometric Friends

We’re ready to ask again: what makes the hypergeometric probability distribution hypergeometric? The answer lies in its probability generating function. The generating function appears when we assemble the possible values of a random variable $X$ with a hypergeometric probability distribution into an infinite series:

\[\begin{align*}
G(z) &= \sum_0^\infty \mathrm{Pr}(X = k) z^k \\
&= \sum_0^\infty \frac{{K\choose k}{{N-k}\choose {n-k}}}{N \choose n} z^k.
\end{align*} \]

(The coefficients of $z^k$ will eventually become zero, so this is a fancy way of rewriting a finite sum.)

We said that any infinite series where the ratio of terms $a_{k+1}/a_k$ is a rational function of $k$ will be hypergeometric. In this case, the ratio is

\[ \left( \frac{{K\choose {k+1}}{{N-k-1}\choose {n-k-1}}}{N \choose n} \right) / \left( \frac{{K\choose k}{{N-k}\choose {n-k}}}{N \choose n} \right).\]

This simplifies to a ratio of polynomials involving the constants $N$, $K$, and $n$ in the variable $k$.

What’s the resulting hypergeometric series? Factoring out an overall constant, one can write the probability generating function as

\[G(z) = \frac{(N-n)!(N-K)!}{N!(N-K-n)!} {}_2 F_1 (-n, -K; N-K-n+1 \mid z).\]

Practical applications of probability generating series typically involve manipulating the series and plugging in specific values of $z$. But let’s take a minute to admire $ {}_2 F_1 (-n, -K; N-K-n+1 \mid z)$. We’ll use the values from our diamond-hunting problem, $n=8$, $K=13$, and $N=52$. Here’s the series plotted as a function of $z$:

Plot of the hypergeometric function 2F1(-8,-13, 52-13-8-1 | z) shows a function tending toward infinity as z goes to + or - infinity, with a local minimum close to z=-19 and very close to the z-axis when z is close to 0.

The complicated behavior reflects its definition as a function with many interesting derivatives!

Leave a Reply

Your email address will not be published. Required fields are marked *

HTML tags are not allowed.

70,437 Spambots Blocked by Simple Comments