Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import time
- start = time.time()
- N_C = 0.0
- n = 99998
- for x in range(0, n):
- x2 = np.random.rand()**2
- y2 = np.random.rand()**2
- if ((x2 + y2)**0.5) < 1.0:
- N_C += 1
- mypi = (float(N_C) / n) * 4
- print(mypi)
- print(np.pi)
- end = time.time()
- elapsed_time = end - start
- print('Time Taken: ', elapsed_time,'seconds')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement