Created
March 21, 2022 12:49
-
-
Save mtrencseni/00b27a5b55e5aaed38bb674127167dc3 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 time import time | |
| from random import random | |
| from statistics import mean, stdev | |
| def coin_flip(bias=0.5): | |
| if random() < bias: | |
| return 1 | |
| else: | |
| return 0 | |
| def make_biased_coin(bias=None): | |
| if bias is None: | |
| bias = random() | |
| print(f'Bias = {bias:.3f}') | |
| return lambda: coin_flip(bias) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment