In [1]:
import numpy as np
from scipy.special import factorial

Using one of each card can be thought of as a one dimensional random walk which follows Pascal's triangle.

The column index of Pascal's triangle gives us the number of drinks we have purchased on one card. We are interested in the 50th column, because we know we have purchased 50 drinks on one card.

The row index tells us the total number of drinks purchased. The entry at the row and the column gives us the number of times such an event will occur.

From there we can characterize the entire distribution of number of drinks on the other card.


In [2]:
def pascal(n, k):
    # compute Pascal's triangle for the nth row and the kth column
    return factorial(n)/(factorial(k) * factorial(n - k))

In [3]:
N = sum(pascal(n, 50) for n in range(50, 101))

In [4]:
print(f"Probability to have drinks left on other card: {(1 - pascal(100, 50)/N)*100.:.3f}%")


Probability to have drinks left on other card: 49.505%

In [5]:
print(f"Expected number of drinks on other card: {50-sum(((n - 50.) * pascal(n, 50))/N for n in range(50, 101)):.3f}")


Expected number of drinks on other card: 0.962