Professional Documents
Culture Documents
Code 3 3 Classical Montecarlo Integration
Code 3 3 Classical Montecarlo Integration
# INPUTS
rn.seed(12345) # set seed of random sequence to 12345
N = 100 # number of simulations
a = -2 # start integration interval
b = +5 # end integration interval
x_vector = np.zeros(N)
f_vector = np.zeros(N)
def f_integrand(x):
result = -pow(x,3) + 5*pow(x,2) - x + 17 # function to integrate
return result