Skip to content

Instantly share code, notes, and snippets.

@Nydhal
Created December 4, 2019 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nydhal/c0bf7bfb9c852b474ac4b500d4db8a10 to your computer and use it in GitHub Desktop.
Save Nydhal/c0bf7bfb9c852b474ac4b500d4db8a10 to your computer and use it in GitHub Desktop.
Python Simulation of the Coupon Collector Problem Expectation a.k.a Mean Cover Time of a Random Walk on a Complete Graph K_n (n=52, 10000 trials).
import random as rd
for _ in range(10000): seen, n_draws = set(), 0
while len(seen)<52:
seen.add(rd.randint(1,52))
n_draws +=1
result.append(n_draws)
print (sum(result) / len(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment