I have an indetntation issue with my code:
#!/usr/bin/python
import numpy as np
#Hit and mess method
A=0 #Integral left limit
B=1 #Integral right limit
C=1.0 #Maximum function value in interval [a,b]
N=100000 #Number of experiments
L=[10**x for x in range(7)] #List of powers of ten (1,10,100,...)
def F(X): #Function to integrate
return np.sqrt(1-(X**2))
for M in L:
NA=0 #Number count of hits
for J in range(M):
U=np.random.rand()
V=np.random.rand()
X=A+(B-A)*U
if F(X) > C*V:
NA=NA+1
P=NA/float(M) #Probability
I=C*(B-A)*P #Integral value
STD=np.sqrt(P*(1-P)/M)*C*(B-A)
print M,NA,P,I,STD
The error is:
File "HIT.py", line 19 U=np.random.rand() ^ IndentationError: expected an indented block
Thanks!