title: Monte Carlo Integration with Python
body: <p>Estimate the following integral with Monte Carlo integration: </p>
  
  <p><img src="https://i.stack.imgur.com/8kTCj.png" alt=""></p>
  
  <p>I am trying to do Monte Carlo Integration on the problem below, where p(x) is a Gaussian distribution with a mean of 1 and a variance of 2. (see image).</p>
  
  <p>I was told that once we draw samples from a normal distribution the pdf vanishes in the integral. Please explain this concept and how do I solve this in Python. Below is my attempt. </p>
  
  <pre><code>def func(x):
  return (math.exp(x))*x
  
  mu = 1
  sigma = sqrt(2)
  N = 1000
  areas = []
  for i in range(N):
      xrand = np.zeros(N)
  
      for i in range (len(xrand)):
          xrand[i] = np.random.normal(mu, sigma)
          integral = 0.0
  
      for i in range (N):
          integral += func(xrand[i])/N
  
      answer = integral
      areas.append(answer)
  
  plt.title("Distribution of areas calculated")
  plt.hist(areas, 60, ec = 'black')
  plt.xlabel("Areas")
  
  integral
  </code></pre>