TITLE: What is the space, on which a random variable is defined?
QUESTION [5 upvotes]: Well, I have some simple, maybe silly question about random variables, but there is something that I can not undestand when we define them. Suppese that, we have some random variable $X$, that is defined in a standard probability space $(\Omega,\mathcal{F}_s,\mathbb{P})$, where $\mathbb{P}:\mathcal{F}_s\rightarrow [0,1]$. I struggle to undestand which is the space , that this random variable is defined. Specifically, the random variable $X$ is a function $X:\Omega\rightarrow R$, where R is some arbitrary space and probabyly the real line.
Can we claim that $X\in L^2(\Omega,\mathcal{F}_s,\mathbb{P})$ or this is wrong? How can we know indeed where this random variable belongs to? 
Maybe my whole skeptic is wrong, so forgive me in advance, but I am a begginer, who wants to understand, this mathematical theory!

REPLY [3 votes]: Here's a few of the basic definitions.
Given your setup, a random variable is a function $X : \Omega \to \mathbb R$, that is, it is a function whose domain is $\Omega$.
But not just any old function from $\Omega$ to $\mathbb R$ is allowed as a random variable. There is a requirement, namely that for every open interval $(a,b) \subset \mathbb R$, the set $X^{-1}(a,b) = \{\omega \in \Omega \mid X(\omega) \in (a,b)\}$ is an element of the $\sigma$-algebra $\mathcal F_s$. In other words, $X^{-1}(a,b)$ is required to be an event.
Because of this requirement, we can define the expectation of a random variable $X$ as an integral, namely
$$E(X) = \int_\Omega X \, d \mathbb P
$$
Now as I have stated this so far, that integral might be infinite. So, one might wish to impose one more requirement on the definition of a random variable, namely that $E(X)$ is finite. This would be equivalent to requiring that $X \in L^1(\Omega, \mathcal F_s, \mathbb P)$.