First Illustration of the Use of Monte-Carlo Methods, integration

Setting \( h=(b-a)/N \) where \( b=1 \), \( a=0 \), we can then rewrite the above integral as $$ \begin{equation*} I=\int_0^1 f(x)dx\approx \frac{1}{N}\sum_{i=1}^Nf(x_{i-1/2}), \end{equation*} $$ where \( x_{i-1/2} \) are the midpoint values of \( x \). Introducing the concept of the average of the function \( f \) for a given PDF \( p(x) \) as $$ \begin{equation*} \langle f \rangle = \sum_{i=1}^Nf(x_i)p(x_i), \end{equation*} $$ and identify \( p(x) \) with the uniform distribution, viz. \( p(x)=1 \) when \( x\in [0,1] \) and zero for all other values of \( x \). The integral is is then the average of \( f \) over the interval \( x \in [0,1] \) $$ \begin{equation*} I=\int_0^1 f(x)dx\approx \langle f \rangle. \end{equation*} $$