Skip to content

Instantly share code, notes, and snippets.

@Vayel
Last active July 27, 2018 15:22
Show Gist options
  • Select an option

  • Save Vayel/13393f5f21f4f4a6012ae85dfc09e53a to your computer and use it in GitHub Desktop.

Select an option

Save Vayel/13393f5f21f4f4a6012ae85dfc09e53a to your computer and use it in GitHub Desktop.
import random
# A stochastic model with a single input `p` and a single output `side`
def coin_model(p):
# Mathematically, `side_output` is a random variable
def side_output():
return 'tail' if random.random() < p else 'head'
return side_output
if __name__ == '__main__':
setup_model = coin_model(0.7)
runs = 5
for _ in range(runs):
print(setup_model())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment