Created
April 17, 2021 01:42
-
-
Save ricbit/5e30001b73b0c385c1a44d08e7ef4306 to your computer and use it in GitHub Desktop.
Expected number of packs to complete an album (linear)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
evalue = [0] * 181 | |
norm = math.comb(180, 4) | |
for i in range(1, 181): | |
ans = math.comb(i, 0) * math.comb(180 - i, 4 - 0) / norm | |
for k in range(1, 5): | |
if i - k >= 0: | |
px = math.comb(i, k) * math.comb(180 - i, 4 - k) / norm | |
ans += px * (1 + evalue[i - k]) | |
ans /= 1 - math.comb(180 - i, 4) / norm | |
evalue[i] = ans | |
print(i, evalue[i]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment