Mathematics - Pi

> Mathematics

1 - PySpark

import random
num_samples = 100000000
def inside(p):     
  x, y = random.random(), random.random()
  return x*x + y*y < 1
count = sc.parallelize(range(0, num_samples)).filter(inside).count()
pi = 4 * count / num_samples
print(pi)
sc.stop()
mathematics/pi.txt · Last modified: 2019/06/06 12:07 by gerardnico