# What is a random variable?

S is a sample space associated with the experiment E.

Random variable is then: Function X, which assigns a real number to every element s ∈ S.

X: S -> R

R is the set of all real numbers.

## Example

Suppose we are tossing 2 coins.

Our sample space would be:

S = {HH, HT, TH, TT}

We can declare a random variable:

Number of heads

```
f(HH) = 2
f(HT) = 1
f(TH) = 1
f(TT) = 0
```