1from numba import jit
2import random
3
4@jit(nopython=True)
5def monte_carlo_pi(nsamples):
6 acc = 0
7 for i in range(nsamples):
8 x = random.random()
9 y = random.random()
10 if (x ** 2 + y ** 2) < 1.0:
11 acc += 1
12 return 4.0 * acc / nsamples