Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- import numpy as np
- import matplotlib.pyplot as plt
- num_experiments = int(input("Enter the number of times you would like to execute this experiment: "))
- heads = np.random.binomial(100, 0.5, num_experiments)
- experiment_totals = 200*heads - (100 * (100-heads))
- plt.bar(list(range(1, num_experiments + 1)), experiment_totals)
- plt.ylabel("Total Money")
- plt.xlabel("Instance of Experiment")
- plt.show()
- 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