Random variables

In a random experiment, a random variable (in short RV) is a numerical property or outcomes or events. For example, if we randomy select a person in a room, the weight of a person is a random variable, or the body height. We introduce the concept of random variables with an example and introduce new notation.

A box contains 1010 balls of colors red, green, and blue. Also, each ball has an exact weight of 3.1kg3.1\,kg, 3.2kg3.2\,kg or 4.1kg4.1\, kg (see figure). We select a ball at random.

There are a couple of events we might be interested in, such as what color we pick

R="color is red",B="color is blue",G="color is green"R=\text{"color is red"}, B=\text{"color is blue"}, G=\text{"color is green"}

or the weight

W1="weight is 3.1",W2="weight is 3.2",W3="weight is 4.1",W_1=\text{"weight is 3.1"}, W_2=\text{"weight is 3.2"},W_3=\text{"weight is 4.1"},

We already require quite a lot of event names, like RR, BB, W1W_1, and so on. With more colors or weights this problem gets worse. A random variable allows us to employ a more systematic way to denote events. They are used primarily for the numerical aspects of events (in this example the weight).

To be more precise, a random variable is simply a function, which has as inputs the possible outcomes of the experiment (the balls), and as output a number (the weight). Let us call this function WW (for "weight"). So for this experiment the machine WW is basically a scale.

It is important to note that this mapping from balls to weights, which is done with a function or machine, is in no way random and could be done entirely outside the context of probability theory. The machine simply takes a ball and spits out its weight. What makes the output random is the fact that input is random. Indeed, every time we perform the experiment of randomly choosing a ball, and we observe the output of the machine, we see that this output changes randomly.

We now introduce an important notation. Observe that the machine can map different inputs (outcomes of experiments) to the same output (weight). In the figure above, for example, there are several balls with weight 3.13.1. We denote the set of all inputs with the same output 3.13.1 by

W=3.1W=3.1

This denotes a subset of the sample space, thus it is an event, the event "weight is 3.1 kg". Similarly, all inputs to the function (or outcomes of the experiment) with the same output 3.23.2 is denoted by

W=3.2W=3.2

This is the event "weight is 3.2 kg", and thus, the event"weight is 4.1 kg" is

W=4.1W=4.1

There are two advantages using this notation. First, as already mentioned, we do not need so many letters for events, and second, this notation is very descriptive - it is immediately clear that the event W=3.1W=3.1 concerns all inputs with weight 3.1kg3.1 kg, something that is not necessarily clear with the notation W1,W2W_1, W_2 and W3W_3.

The name random variable is a bit misleading, as WW is simply a function from the sample space to numerical values. However, we can also regard WW as a variable (place holder) for the weight, which then changes its value randomly with every repetition of the experiment.

Two interesting facts:

Let's define random variables for a general random experiment:

Definition 1

Consider a random experiment. A function XX from the sample space S={o1,...,on}S=\{o_1, ..., o_n\} to a set of values {x1,...,xr}\{x_1, ..., x_r\} is called a random variable. The event "An outcome with value xkx_k occurred" is denoted by

X=xkX=x_k

Consider an arbitrary number xx. We introduce the following notations:

  • XxX\leq x is the event "an outcome with value x\leq x". It is the union of all events X=xkX=x_k with xkxx_k\leq x.
  • X<xX< x is the event "an outcome with value <x< x". It is the union of all events X=xkX=x_k with xk<xx_k< x.
  • XxX\geq x is the event "an outcome with value x\geq x". It is the union of all events X=xkX=x_k with xkxx_k\geq x
  • X>xX> x is the event "an outcome with value >x> x". It is the union of all events X=xkX=x_k with xk>xx_k> x.
  • X[a,b]X\in [a,b] is the event "an outcome with value in interval [a,b][a,b] occurred". Clearly, it is the union of all events X=xkX=x_k with xk[a,b]x_k\in [a,b]. Often, we also use the notation aXba\leq X\leq b.

Furthermore, it is straight forward to show the following:

Theorem 1
  1. the events X=xkX=x_k and X=xlX=x_l are mutually exclusive for klk\neq l.
  2. the events X=x1,X=x2,...,X=xrX=x_1, X=x_2, ..., X=x_r form a partition of SS.
  3. the event X=xX=x is empty if xx is not one of the values x1,...,xrx_1, ..., x_r.
Exercise 1

The random experiment is flipping a coin 33 times. The random variable is NN="number of observed heads".

  1. What is N(HHT)=N(HHT)=?

  2. What are the possible outputs of the function NN?

  3. Express the event N=2N=2 using the different outcomes of the experiment.

  4. Show that the events N=1N=1 and N=2N=2 are mutually exclusive.

  5. Show that the events N=0N=0, ..., N=3N=3 are pairwise mutually exclusive, and form a partition of SS.

  6. Express the events N<2.1,N>1,N1,N[0.5,2.2]N<2.1, N>1, N\leq1, N\in [0.5,2.2] as a union of some of the events N=0,N=1,N=2,N=3N=0, N=1, N=2, N=3.

Solution
  1. N(HHT)=2N(HHT)=2 (two heads)
  2. 0,1,2,30, 1, 2,3
  3. N=2N=2\, = {HHT,HTH,THH}\{HHT, HTH, THH\}
  4. Clearly, (N=1N=2)={}(N=1 \cap N=2) =\{ \} because if there were an outcome in the intersection, this outcome would have exactly one head and also exactly two heads, which does not make sense.
  5. We have to show that (N=i)(N=j)={}(N=i) \cap (N=j) =\{ \} for iji\neq j. This is clearly so, because an outcome in the intersection would have to have exactly ii heads and also exactly jj heads, which does not make sense.
  6. We have
    • N<2.1=(N=0N=1N=2)N<2.1\,\, = (N=0 \cup N=1 \cup N=2)
    • N>1=(N=2N=3)N> 1\,\, = (N=2 \cup N=3)
    • N1=(N=0N=1)N\leq 1\,\, = (N=0 \cup N=1)
    • N[0.5,2.2]=(N=1N=2)N\in [0.5,2.2] = (N=1 \cup N=2)
Exercise 2

A die is rolled twice. Consider the three random variables:

  • AA="sum of the two numbers"
  • HH="the number which is higher (if they are equal just take the first one)"
  • DD="the absolute value of the difference of the two numbers"
  1. The first roll shows a 5, the second one a 6. Determine the output of the three random variables for this outcome.
  2. Determine the possible values of the random variables A,HA, H and DD.
  3. Determine p(3A5),p(H>4),p(D4)p(3 \leq A \leq 5), p(H>4), p(D\leq 4) directly or with the help of the union of the events X=x1,...,X=xrX=x_1,...,X=x_r (where XX is AA, HH, or DD).

Hint: the absolute value of a number is the positive part of the number. For example, the absolute value of 3-3 is 33. We write 3=3\vert -3\vert =3.

Solution
  1. A(56)=11,H(56)=6,D(56)=1A(56)=11, H(56)=6, D(56)=1

  2. We have

    • The sample space is

      +123456123456723456783456789456789105678910116779101112\begin{array}{l|ccccc} \text{+} & 1 & 2 & 3 & 4 & 5 & 6 \\\hline 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ 3 & 4 & 5 & 6 & 7 & 8 & 9 \\ 4 & 5 & 6 & 7 & 8 & 9 & 10 \\ 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ 6 & 7 & 7 & 9 & 10 & 11 & 12 \\ \end{array}

      Possible outputs: {2,3,4,...,11,12}\{ 2,3,4,..., 11, 12\}

    • The sample space is

      max123456112345622234563333456444445655555566666666\begin{array}{l|ccccc} \text{max} & 1 & 2 & 3 & 4 & 5 & 6 \\\hline 1 & 1 & 2 & 3 & 4 & 5 & 6 \\ 2 & 2 & 2 & 3 & 4 & 5 & 6 \\ 3 & 3 & 3 & 3 & 4 & 5 & 6 \\ 4 & 4 & 4 & 4 & 4 & 5 & 6 \\ 5 & 5 & 5 & 5 & 5 & 5 & 6 \\ 6 & 6 & 6 & 6 & 6 & 6 & 6 \\ \end{array}

      Possible outputs: {1,2,3,4,5,6}\{ 1,2,3,4,5,6\}

    • The sample space is

      diff123456101234521012343210123432101254321016543210\begin{array}{l|ccccc} \vert \text{diff}\vert & 1 & 2 & 3 & 4 & 5 & 6 \\\hline 1 & 0 & 1 & 2 & 3 & 4 & 5 \\ 2 & 1 & 0 & 1 & 2 & 3 & 4 \\ 3 & 2 & 1 & 0 & 1 & 2 & 3 \\ 4 & 3 & 2 & 1 & 0 & 1 & 2 \\ 5 & 4 & 3 & 2 & 1 & 0 & 1 \\ 6 & 5 & 4 & 3 & 2 & 1 & 0 \\ \end{array}

      Possible outputs: {0,1,2,3,4,5}\{ 0,1,2,3,4,5\}

  3. Direct (counting the relevant outcomes): p(3A5)=936=14p(3 \leq A \leq 5) = \frac{9}{36}=\frac{1}{4}, p(H>4)=2036=59p(H> 4) = \frac{20}{36}=\frac{5}{9}, p(D4)=3436=1718p(D\leq 4) = \frac{34}{36}=\frac{17}{18}. With the union:

    p(3A5)=p(A=3A=4A=5)=p(A=3)+p(A=4)+p(A=5)=236+336+436=936=14p(H>4)=p(H=5H=6)=p(H=5)+p(H=6)=936+1136=2036=59p(D4)=p(D=0D=2D=3D=4)=p(D=0)+p(D=1)+p(D=2)+p(D=3)+p(D=4)=636+1036+836+636+436=3436=1718\begin{array}{lll} p(3 \leq A \leq 5) & = &p(A=3 \cup A=4 \cup A=5)\\ &=& p(A=3)+p(A=4)+p(A=5)\\[0.2em] &=&\frac{2}{36}+\frac{3}{36}+\frac{4}{36}\\[0.2em] &=& \frac{9}{36} = \frac{1}{4}\\ & & \\ p(H>4) & = &p(H=5 \cup H=6)\\ &=& p(H=5)+p(H=6)\\[0.2em] &=&\frac{9}{36}+\frac{11}{36}\\[0.2em] &=& \frac{20}{36} = \frac{5}{9}\\ & & \\ p(D\leq 4) & = &p(D=0 \cup D=2 \cup D=3 \cup D=4)\\ &=& p(D=0)+p(D=1)+p(D=2)+p(D=3)+p(D=4)\\[0.2em] &=&\frac{6}{36}+\frac{10}{36}+\frac{8}{36}+\frac{6}{36}+\frac{4}{36}\\[0.2em] &=& \frac{34}{36} = \frac{17}{18} \end{array}