Created
May 15, 2016 16:28
-
-
Save ludobouan/c83b75f241c074790b928262296b2e88 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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