I am trying to process a Monte Carlo Algorithm to calculate the value of pi. When I try to give a large input as mentioned in the program below. I get a memory error. What should i do to rectify it? The code is a s follows:
def PiCalc():
N_ok=0
n=1000000000000
for i in range(n):
x=random()
y=random()
if sqrt(x**2 + y**2) <= 1:
N_ok+=1
pi= 4.0 * N_ok / n
print "No. of points inside the circle: ", N_ok
print "Pi: ", pi
return pi