Skip to content

Minor change to coinflip logic #6

Description

@slawdogporsche

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions