Search This Blog

Wednesday, January 5, 2011

Value of pi using Monte Carlo Method

#To determine value of pi using Monte Carlo Method
from random import *
j=0
for i in range(10000000):
    x=random()
    y=random()
    if (x**2+y**2)<=1:j+=1
print "Value of pi = ",4.0*j/i

by Prof. Purushothaman Vadakkedam

No comments:

Post a Comment