Created
November 16, 2017 07:17
-
-
Save shreyansh26/72085797f25d99e97b74dd26bf42924e to your computer and use it in GitHub Desktop.
This file contains 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
import numpy as np | |
from numba import jit | |
@jit | |
def aprox_pi(N): | |
points = 2 * np.random.rand(N, 2) - 1 | |
M = 0 | |
for k in range(N): | |
if points[k,0]**2 + points[k,1]**2 < 1.: | |
M += 1 | |
return 4.*M/N | |
print(aprox_pi(1e8)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment