Expectation of composition of functions with density as R-N derivative In prior probability courses, I've always seen and used the fact that, for a continuous random variable X and a function $\phi$, $E[\phi(X)]=\int_{ \mathbb{R}}\phi(x) f_X(x)dx,$ but I cannot find a rigorous statement of such a theorem listing all of the necessary assumptions on $X$ or $\phi$ in any of my probability references. I'm currently trying to reconcile my previous probability knowledge and what I've learned in my measure theory course, using Rudin's "Real and Complex Analysis" and would like to prove this result. My questions are:


*

*Is my understanding of the set up correct, and is the proof of my result below correct?

*Can the theorem below be strengthened?


Theorem:
Let $(X, \mathcal{M}, \mu)$ be a positive measure space with $\mu(X)=1$, and let $g \in L^1(\mu)$ be a real "absolutely continuous" function with density $f:\mathbb{R} \to \mathbb{R}$. If $\phi: \mathbb{R} \to \mathbb{R}$ is absolutely continuous on $[a,b]$ for every $a,b \in \mathbb{R}$ and $\lim_{t \to -\infty} \phi(t)=0$ with $\phi' \in L^1(\mathbb{R})$, then
$$\int_X \phi \circ g d\mu = \int_{\mathbb{R}}\phi f dm.$$
SET UP: Define $F: \mathbb{R} \to \mathbb{R}$ by $F(x) = \mu(g \leq x)$, the distribution function of $g$. Keeping things general, let $F_-$ be the left continuous function agreeing with $F$ on all points of continuity (this function won't matter once absolute continuity is defined, but it is necessary in general). Define $\Lambda: C_c(\mathbb{R}) \to \mathbb{C}$ by $\Lambda(h)=\int_{\mathbb{R}} h dF_-$ (the Riemann-Stieltjes integral). Since $F$ is bounded and monotone, $F \in BV$, so $\Lambda$ is well defined and forms a positive linear functional. The Riesz representation theorem implies the existance of a measure $F_*$ on $\mathbb{R}$ so that $F_-(b)-F_-(a) = F_*([a,b))$ for all real $a < b$. (as in Rudin's exercise 7.12). We say $g$ is "absolutely continuous" if $F_* << m$, in which case the density of $g$ is $f:= dF_*/dm.$  Note that if $g$ is absolutely continuous, it follows that $F_-=F.$
Proof
I first show that $\int_X \phi \circ f d\mu=\int_{\mathbb{R}}\mu(g > t) \phi'(t)dt$, and the proof closely follows that of Rudin's theorem 8.16 about distribution functions.
Define $E=\{(x,t): g(x) > t\} \subset X \times \mathbb{R}$, which Rudin argues is measurable for positive $g$, so taking the positive and negative parts of $g$ implies that $E$ is measurable. Also, observe that $\int_X \int_{\mathbb{R}} |\chi_E(x,t) \phi'(t)|dt d\mu(x) \leq \int_X ||\phi'||_{L^1(\mathbb{R})} d\mu < \infty.$ Therefore, Fubini's theorem implies that 
$$\int_{\mathbb{R}}\mu(g>t)\phi'(t)dt =\int_{\mathbb{R}}\int_X \chi_E(x,t)\phi'(t) d\mu(x) dt =\int_X \int_{\mathbb{R}} \chi_E(x,t) \phi'(t)dt d\mu(x) =$$ $$\int_X \int_{-\infty}^{g(x)} \phi'(t) dt d\mu(x) .$$
Since $\phi' \in L^1(\mathbb{R})$, the dominated convergence theorem and absolute continuity imply that this equals $\int_X \phi(g(x))-\phi(-\infty) d\mu(x)= \int_X \phi \circ g d\mu.$
Also,
$$\int_{\mathbb{R}}\mu(g > t) \phi'(t)dt = \int_{\mathbb{R}}(1-F(t)) \phi'(t)dt = \int_{\mathbb{R}}\int_{t}^{\infty}f(x)\phi'(t)dx dt.$$
A similar argument as before implies that Fubini's theorem applies to this integral, and therefore
$$\int_X\phi \circ g d\mu= \int_{\mathbb{R}}\int_{-\infty}^{x}f(x) \phi'(t) dt dx = \int_{\mathbb{R}} f(x)(\phi(x)-\phi(-\infty))dx=\int_{\mathbb{R}}\phi f dm.$$
Note that the second to last equality holds again by the dominated convergence theorem, since $\phi$ is absolutely continuous and $\phi' \in L^1(\mathbb{R})$.
 A: It is true even for arbitrary random variables, and you need a framework that handles both simultaneously. Without going too deep into probability theory, all (real-valued) random variables $X$, continuous or not, induce a measure on the reals, via $\mu_X(E) = \mathrm{Pr}(X \in E)$. Continuous random variables induce measures that are absolutely continuous (and thus by Radon Nikodym can be expressed as a density function integration $\mu_X(E) = \int_E f_X(x) dx$. Here $dx$ is Lebesgue measure).  
Now if you think about what $\phi(X)$ is, (also a random variable), we can also look at $\mu_{\phi(X)}(E) = \mathrm{Pr}(\phi(X) \in E) = \int_{\phi(X)\in E} d\mu_X = \int_{\phi^{-1}(E)} d\mu_X$.
Well, at this point you can use standard real analysis methods to show  that $\int_{\mathbb{R}} g(t) d\mu_{\phi(X)}(t) = \int_{\mathbb{R}} g(\phi(t)) d\mu_X(t)$, first showing that it is true for indicators on intervals, and transferring to step functions, and then continuous functions. Since the goal is to obtain the result for $g(x)=x$ you can stop once you get to continuous functions. And then you have the formula for expectation you know and love.
That being said, you will probably want to study probability theory from a measure-theoretic perspective, and this will make even more sense.
A: Okay, based on the discussion above, I have the following theorem after converting back to more Rudinesque language and filling in all of the details:
Let $(X,\mathcal{M},\mu)$ be a measure space, $g: X \to \mathbb{R}$ measurable, and $\phi: \mathbb{R} \to \mathbb{R}$ Borel measurable so that $\phi \circ g \geq 0$ or $\phi \circ g \in L^1(\mu)$. If $\mu_g(E):=\mu(g^{-1}(E))$ for all Borel $E \subset \mathbb{R}$, then $\int_X \phi \circ g d\mu = \int_{\mathbb{R}}\phi d\mu_g$. Moreover, if $\mu(X) < \infty$ and $\mu_g << m$ ($m=$ Lebesgue measure on the Borel sets), then $\int_X \phi \circ g d\mu = \int_{\mathbb{R}}\phi f dm$, where $f = d\mu_g /dm$ is the Radon Nikodym derivative.
Proof: If $E$ is real Borel set, $\int_X \chi_E \circ g d\mu =\int_{g^{-1}(E)}1 d\mu = \mu_g(E)= \int_{\mathbb{R}}\chi_E d\mu_g.$ For a positive simple function $s = \sum a_i \chi_{E_i}, \int_X s \circ g d\mu= \sum a_i \int_{g^{-1}(E_i)}d\mu=\sum a_i \int_{E_i}d\mu_g=\int_{\mathbb{R}}sd\mu_g.$ Let $\phi$ be a positive Borel function, and let $s_n$ be positive simple functions converging up to $\phi$. Then $s_n \circ g$ are positive simple functions converging to $\phi \circ g,$ so the monotonic convergence theorem implies that the theorem holds for positive $\phi,$ and the $ \phi \circ g \in L^1(\mu)$ case follows from taking the positive and negative parts. This proves the first part of the theorem.
Given $\mu(X) < \infty$ and $\mu_g << m$, then $\int_X \phi \circ g d\mu = \int_{\mathbb{R}}\phi d\mu_g =\int_{\mathbb{R}}\phi f dm.$
