Integrate the pdf of a standard normal distribution from $-\infty$ to $-2$ $f(x)=\frac{1}{\sqrt{2\pi}} exp(-\frac{y^2}{2}))$
In [1]:
import numpy as np
In [2]:
N = 1000
x = np.random.rand(N)
b = -2
In [3]:
y = 1 – 1/x + b
In [4]:
fy = 1/(2*np.pi)**0.5*np.exp(-y**2/2)
gx = fy/x**2
np.mean(gx)
Out[4]:
0.022988828703523003
In [ ]: