Last active
July 27, 2018 15:22
-
-
Save Vayel/13393f5f21f4f4a6012ae85dfc09e53a to your computer and use it in GitHub Desktop.
Revisions
-
Vayel revised this gist
Jul 27, 2018 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,7 @@ # `p` is the probability of throwing tail # `side` is either 'head' or 'tail' def coin_model(p, seed=None): # The seed allows us to control randomness and ensure reproducibility random.seed(seed) # Mathematically, `side_output` is a discrete random variable @@ -13,7 +13,7 @@ def coin_model(p, seed=None): return side_output if __name__ == '__main__': coin = coin_model(0.7, seed=123) runs = 5 for _ in range(runs): print(coin()) -
Vayel revised this gist
Jul 23, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ def coin_model(p, seed=None): random.seed(seed) # Mathematically, `side_output` is a discrete random variable # with a Bernoulli distribution B(p) (1 is 'tail' and 0 is 'head') side_output = lambda: 'tail' if random.random() < p else 'head' return side_output -
Vayel revised this gist
Jul 23, 2018 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,8 +9,7 @@ def coin_model(p, seed=None): # Mathematically, `side_output` is a discrete random variable # with a Bernoulli distribution B(p) (1 being 'tail' and 0 'head') side_output = lambda: 'tail' if random.random() < p else 'head' return side_output if __name__ == '__main__': -
Vayel revised this gist
Jul 23, 2018 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -4,7 +4,9 @@ # `p` is the probability of throwing tail # `side` is either 'head' or 'tail' def coin_model(p, seed=None): # The seeds allows us to control randomness and ensure reproducibility random.seed(seed) # Mathematically, `side_output` is a discrete random variable # with a Bernoulli distribution B(p) (1 being 'tail' and 0 'head') def side_output(): -
Vayel revised this gist
Jul 23, 2018 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,18 @@ import random # A stochastic model with a single input `p` and a single output `side` # `p` is the probability of throwing tail # `side` is either 'head' or 'tail' def coin_model(p, seed=None): random.seed(seed) # Mathematically, `side_output` is a discrete random variable # with a Bernoulli distribution B(p) (1 being 'tail' and 0 'head') def side_output(): return 'tail' if random.random() < p else 'head' return side_output if __name__ == '__main__': setup_model = coin_model(0.7, seed=123) runs = 5 for _ in range(runs): print(setup_model()) -
Vayel revised this gist
Jul 19, 2018 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,8 @@ # A stochastic model with a single input `p` and a single output `side` def coin_model(p): # Mathematically, `side_output` is a discrete random variable # with a Bernoulli distribution B(p) def side_output(): return 'tail' if random.random() < p else 'head' return side_output -
Vayel renamed this gist
Jul 19, 2018 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,14 @@ 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()) -
Vayel revised this gist
Jul 19, 2018 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,7 @@ import random def coin_abm(p): # Mathematically, `side_output` is a random variable def side_output(): return 'tail' if random.random() < p else 'head' return side_output -
Vayel revised this gist
Jul 19, 2018 . 1 changed file with 5 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,11 +2,11 @@ def coin_abm(p): def side_output(): return 'tail' if random.random() < p else 'head' return side_output if __name__ == '__main__': configured_coin_abm = coin_abm(0.7) runs = 5 for _ in range(runs): print(configured_coin_abm()) -
Vayel created this gist
Jul 19, 2018 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ import random def coin_abm(p): def side_output(): return 'tail' if random.rand() < p else 'head' return side_output if __name__ == '__main__': configured_coin_abm = coin_abm(0.8) print(configured_coin_abm()) print(configured_coin_abm()) print(configured_coin_abm())