Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor change to coinflip logic #6

Open
slawdogporsche opened this issue Jun 5, 2022 · 0 comments
Open

Minor change to coinflip logic #6

slawdogporsche opened this issue Jun 5, 2022 · 0 comments

Comments

@slawdogporsche
Copy link

The plt render should be moved back one indentation, since you're really only interested in the final result and it saves you 5000 unnecessary renders

def monte_carlo(n):
results = 0
for i in range(n):
flip_result = coin_flip()
results = results + flip_result

	prob_value = results/(i+1)

	list1.append(prob_value)

plt.axhline(y=0.5, color ='r', linestyle='-')
plt.xlabel("Iterations")
plt.ylabel("Probability")
plt.plot(list1)

return results/n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant