Skip to content

Instantly share code, notes, and snippets.

@mattf
Created April 28, 2017 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattf/e15fb4dcddc81d08f30a502cc4e7adfc to your computer and use it in GitHub Desktop.
Save mattf/e15fb4dcddc81d08f30a502cc4e7adfc to your computer and use it in GitHub Desktop.
shell pi test, pyspark
import random
def inside(p):
x, y = random.random(), random.random()
return x*x + y*y < 1
count = spark.sparkContext.parallelize(xrange(0, 100000000)).filter(inside).count()
print "Pi is roughly %f" % (4.0 * count / 100000000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment