Proving if $X$ is a random variable and $f$ is a continuous function, then $f(X)$ is a random variable I'm reading "Fundamental of Mathematical Statistics" by Gupta and Kapoor and the authors make the claim that "if $X$ is a random variable and $f$ is a continuous function, then $f(X)$ is a random variable". The proof has been skipped as it was beyond the scope of the textbook.
However, here's my question: There's not much information about given about $f$, so I assume $f$ is a real valued function on $\mathbb{R}$. So clearly the composition $f(X)$ is also a random variable. The hypothesis that $f$ is continuous is never used. So, does it mean that $f$ does not have be continuous? Or am I wrong somewhere?
 A: The proof is most likely out of the scope of most undergraduate mathematical statistics/probability courses.
Formally, a random variable is a measurable function from $ \Omega $ to $ E $ where
$ (\Omega, \mathcal{F}, P) $ is a probability space and $ (E, \mathcal{E}) $
is a measurable space.
A well-known result in measure-theoretic probability is that if $ X : \Omega \to E $, and $ f : E \to E $ is
continuous, then $ f \circ X $ is also a measurable function with respect to the previous probability space. This is the result to which the authors are referring.
A: Composition of measurable functions results in a measurable function. 
So it is enough for $f$ to be measurable as a function $f:(\mathbb R,\mathcal B)\to(\mathbb R,\mathcal B)$ where $\mathcal B$ denotes the Borel $\sigma$-algebra. 
So it boils down to the statement that every continuous function is Borel-measurable. 
If $\tau$ denotes the topology on $\mathbb R$ then the continuity of $f$ assures that $f^{-1}(\tau)\subseteq\tau$.
From this it follows directly that: $$\sigma(f^{-1}(\tau))\subseteq\sigma(\tau)=\mathcal B$$
It is true in general that $$\sigma(f^{-1}(\mathcal A))=f^{-1}(\sigma(\mathcal A))$$
For a proof of that see here.
Applying this we find: $$f^{-1}(\mathcal B)=f^{-1}(\sigma(\tau))\subseteq\sigma(\tau)=\mathcal B$$stating exactly that $f$ is measurable.
A: Yes. You're right that $f$ does not have to be continuous. It just merely needs to be measurable. You can think of measurable functions as functions that can be approximated by continuous functions (Lusin's theorem). Measurable functions arise in the study of Lebesgue integration.
This case might be familiar to you as an undergraduate student (like me):
The Lebesgue Theorem for Riemann integration says that a function $f$ is Riemann integrable on $[a,b]$ if and only if the set of the discontinuities of $f$ is a null-set. So, this gives you a class of functions that are not necessarily continuous, but they're measurable.
