Created
October 17, 2022 01:27
-
-
Save galenseilis/e5c1d080a98386b26a4996abd7738d8f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from itertools import chain, combinations | |
| from random import sample | |
| import matplotlib.pyplot as plt | |
| def powerset(iterable): | |
| s = list(iterable) | |
| return chain.from_iterable(combinations(s, r) for r in range(len(s)+1)) | |
| pX = [set(i) for i in powerset(list(range(10)))] | |
| results = [] | |
| N = 1000 | |
| for k in range(10000): | |
| count = 0 | |
| for i in range(N): | |
| A,B = sample(pX, 2) | |
| if A.issubset(B): | |
| count += 1 | |
| else: | |
| continue | |
| results.append(count / N) | |
| plt.hist(results, bins=100) | |
| plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment