Advertisement
Guest User

Samuelson's Problem

a guest
Mar 27th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. num_experiments = int(input("Enter the number of times you would like to execute this experiment: "))
  6.  
  7. heads = np.random.binomial(100, 0.5, num_experiments)
  8. experiment_totals = 200*heads - (100 * (100-heads))
  9.  
  10. plt.bar(list(range(1, num_experiments + 1)), experiment_totals)
  11. plt.ylabel("Total Money")
  12. plt.xlabel("Instance of Experiment")
  13. plt.show()
  14.  
  15. pd.DataFrame(experiment_totals, columns=["Total Money"]).rename_axis("Experiment").to_csv("Coin Toss.csv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement