I was reading this document (I will reproduce the equation):
Monte Carlo Integration
Ravi Ramamoorthi
http://inst.eecs.berkeley.edu/~cs294-13/fa09/lectures/scribe-lecture4.pdf
In which you can find the following series of equations to compute the expected value of the random variable of the integral: $F_n = {(b-a) \over n}\sum_{i=1}^n f(X_i)$.
Here at the equations:
$\begin{array}{l} E[F_n] &=& E\left[{(b-a) \over n}\sum_{i=1}^n f(X_i)\right]\\ &=&{(b-a) \over n}\sum_{i=1}^n E[f(X_i)]\\ &=&{(b-a) \over n}\sum_{i=1}^n \color{\red}{\int_{-\infty}^{\infty}f(x)p(x)dx}\\ &=&{(b-a) \over n}{1 \over (b-a)}\color{\green}{\sum_{i=1}^n\int_{a}^{b}f(x)dx}\\ &=&{1 \over n} \sum_{i=1}^n\int_{a}^{b}f(x)dx\\ &=&I. \end{array}$
So what I don't understand in these equations is how we go from $ E[f(X_i)]$ to $\color{\red}{\int_{-\infty}^{\infty}f(x)p(x)dx}$ and then from an integral from - to + infinity to an integral from a to b (by taking out p(x) which is the probability density function): $\color{\green}{\sum_{i=1}^n\int_{a}^{b}f(x)dx}$.
It would be great if someone could tell me where these substitutions come from.
Thank you very much for your help!