Created
April 28, 2017 19:56
-
-
Save mattf/e15fb4dcddc81d08f30a502cc4e7adfc to your computer and use it in GitHub Desktop.
shell pi test, pyspark
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 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