Created
February 6, 2016 11:22
-
-
Save yasuharu519/57295f7a99032ba5f03f to your computer and use it in GitHub Desktop.
One liner to calculate PI with Monte Carlo method.
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
t=1000000;from random import random as r;print len(filter(lambda(x, y):(pow(x,2)+pow(y,2))<1,[(r(),r())for i in xrange(t)]))/float(t)*4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment