Skip to content

Instantly share code, notes, and snippets.

@mtrencseni
Created March 21, 2022 12:49
Show Gist options
  • Select an option

  • Save mtrencseni/00b27a5b55e5aaed38bb674127167dc3 to your computer and use it in GitHub Desktop.

Select an option

Save mtrencseni/00b27a5b55e5aaed38bb674127167dc3 to your computer and use it in GitHub Desktop.
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