Why random variables is a function? It seems that it violates the definition of function. I am watching Lecture 5 of MIT 6.041 Probabilistic Systems Analysis and Applied Probability. In the lecture, Professor said Random Variable is a function that maps elements from the sample space to a real number. For example, if the sample space is the students in the classroom, a random variable $x$ can be the height of the students.
However, I remember that a function is defined as $\forall a \in A \exists! b \in B((a,b) \in F)$. That means for all inputs, there is one unique output. In the example above, we may have two students with the same height. Will that violate the rule of function? Or Professor just used the word function loosely?
 A: It is not a violation of the definition of a function when two unequal inputs return equal outputs. Rather, the rule is that a single input cannot return more than one output!
For example, when one first is introduced to functions, one is mostly paying attention to things like $f(x) =x^2$, which defines a function from the set of real numbers to the set of real numbers. In this case, there are two "students", say the inputs $x=1$ and $x=-1$, which have the same "height", both inputs give the output of $1$. This is not a problem and $f(x)=x^2$ is definitely a function. The same is true in the context of random variables. Your reading of the definition is just slightly off, is all.
A: Function is Random variable when  pre-image of it's any value is measurable set i.e. probabilistic events. So we can say that function takes it's value with some probability.
Formally lets take $(\Omega, \mathcal{B}, P)$ probability space and random variable $X:\Omega \to \mathbb{R}$. Then $P(X^{-1}(a))$ is probability with $X$ is obtain value $a$.
So random variable of course have fixed rule for input-output connection, it's usual function, but on another hand, defined on  probability space it characterize the random nature of measuring.
