Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ludobouan/c83b75f241c074790b928262296b2e88 to your computer and use it in GitHub Desktop.
Save ludobouan/c83b75f241c074790b928262296b2e88 to your computer and use it in GitHub Desktop.
from numpy import random
incircle = 0
for i in range(1,1000000):
x,y = random.rand(2)
x *= random.choice([-1,1])
y *= random.choice([-1,1])
if x**2 + y**2 < 1:
incircle += 1
print(4*incircle/i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment