I don't like this new tutorial. Take me back to the (very) old tutorial!

Resource

Note To follow this tutorial, you should know what is meant by an experiment and its outcomes, and probability.

What is a random variable?

In many experiments we can assign numerical values to the outcomes. For instance, if you roll a die, each outcome has a value from 1 through 6. If you ascertain the midterm test score of a student in your class, the outcome is again a number. We call a rule that assigns a number to each outcome of an experiment a random variable.

Random variable

A random variable is a rule $X$ that assigns a number, or value, to each outcome in the sample space of an experiment.
 
Examples

  1. Roll a die; $X =$ the number facing up.
        Values of $X:$ $1, 2, 3, 4, 5, 6$
  2. Select a soccer player; $Y =$ the number of goals the player has scored during the season.
        Values of $Y:$ $0, 1, 2, 3, 4, ...$
  3. Flip a coin three times. $Z =$ the number of times heads comes up.
        Values of $Z:$ $0, 1, 2, 3$
Some for you
Types of random variable

A discrete random variable can take on only specific, isolated numerical values, like the outcome of a roll of a die, or the number of stocks in a portfolio. Discrete random variables that can take on only finitely many values (like the outcome of a roll of a die) are called finite random variables. Discrete random variables that can take on an effectively unlimited number of values (like the number of steps in an procedure) are infinite discrete random variables.

A continuous random variable, on the other hand, can take on any values within a continuous range or an interval, like the temperature in Central Park, or the exact height of an athlete in meters.
 
Examples

Random variable \t Values \t Type \\ Roll a die.
$X =$ the number facing up. \t ${0,1,2,3,4,5,6}$ \t Finite
There are only six possible values for $X.$ \\ Select a soccer player.
$Y =$ the number of goals the player has scored during the season. \t $0, 1, 2, 3, 4, ...$ \t Infinite discrete
There is no stated upper limit to the number of goals. \\ Weigh your pile of dirty laundry.
$Z =$ the exact weight in kg. \t All nonnegative real numbers \t Continuous
The weight can be any nonnegative number in a continuous range.

Some for you

Probability distribution of a finite random variable

Given a random variable $X$, then, depending on the outcome of the experiment, there is a certain probability that, for instance, $X$ will turn out to be 2. This probability is the probability of the event that $X = 2$: the event consisting of all outcomes that have an assigned $X$-value of 2. To illustrate this let's look at an exmple: Throw a pair of fair dice, and take $X$ to be the sum of the numbers facing up. Then
Event that $X=2$ \t Event that you throw a 2 \\ \gap[20] $=$ Set of all outcomes that result in a sum of 2 \\ \gap[20] $= \{(1,1)\}$ \\   \\ Event that $X=3$ \t Event that you throw a 3 \\ \gap[20] $=$ Set of all outcomes that result in a sum of 3 \\ \gap[20] $= \{(1,2), (2,1)\}$ \\   \\ Event that $X=4$ \t Event that you throw a 4 \\ \gap[20] $=$ Set of all outcomes that result in a sum of 4 \\ \gap[20] $= \{(1,3), (2, 2), (3,1)\}$ \\   \\ ... \\ Event that $X=12$ \t Event that you throw a 12 \\ \gap[20] $=$ Set of all outcomes that result in a sum of 12 \\ \gap[20] $= \{(6,6)\}$
Each of these events has a certain probability. For instance, the probability that $X = 2$ is $\frac{1}{36}$ because the event that $X = 2$ consists of 1 of the 36 possible (equally likely) outcomes. We write
\t $\displaystyle \qquad P(X = 2) = \frac{1}{36}$. \gap[20] \t The probability that $X = 2$ is $\frac{1}{36}$. \\ \t !4! Similarly, the probability that $X = 3$ is $\frac{2}{36}$ because the event that $X = 3$ consists of 2 of the 36 possible outcomes. \\ \t $\displaystyle \displaystyle \qquad P(X = 3) = \frac{2}{36} = \frac{1}{18}$. \t The probability that $X = 3$ is $\frac{1}{18}$. \\ \t $\displaystyle \displaystyle \qquad P(X = 4) = \frac{3}{36} = \frac{1}{12}$. \t The probability that $X = 4$ is $\frac{1}{12}$. \\ \t $\qquad \cdots$ \\ \t $\displaystyle \displaystyle \qquad P(X = 12) = \frac{1}{36}$. \t The probability that $X = 12$ is $\frac{1}{36}$.

If we tabulate the probabilities of all the possible values of $X$ together, we get the probability distribution of $X$: $\bold{x}$ \t 2 \t 3 \t 4 \t 5 \t 6 \t 7 \t 8 \t 9 \t 10 \t 11 \t 12 \\ $\bold{P(X=x)}$ \t $\frac{1}{36}$ \t $\frac{2}{36}$ \t $\frac{3}{36}$ \t $\frac{4}{36}$ \t $\frac{5}{36}$ \t $\frac{6}{36}$ \t $\frac{5}{36}$ \t $\frac{4}{36}$ \t $\frac{3}{36}$ \t $\frac{2}{36}$ \t $\frac{1}{36}$ Here, the lower case $x$ refers to a possible value of $X$ (upper case). So, $X$ is the name of the random varable, and $x$ is a number. We read $P(X = x)$ as "the probability that $X$ has the value $x$."

We can use a bar graph, called a histogram to visualize a probability distributions like the one above, shown here.
Throw a pair of fair %20-sided dice, and take $X$ to be the sum of the numbers facing up. Fill in the indicated values of the partial probability distribution table. The other missing values will appear when you correctly answer the question (or press "Do it").
%Q #[How well does the line approximate the data? ][¿Qué tan bien aproxima la recta a los datos?]#
%A #[If we use the equation of the line to calculate the $y$-coordinates, we get slightly different values, called predicted values (for which we use the symbol $\hat{y}$) from the original observed values shown in the table.][Si usamos la ecuación de la recta para calcular las coordenadas-$y$, obtenemos valores, llamados valores pronosticados o predichos (para cuales usamos el símbolo $\hat{y}$) un poco distintos de los valores originales observados que se muestra en la tabla.]#

Coin tosses

You can think of a coin as a die with two faces: heads (H) and tails (T).

So, if you toss a coin once, there are two outomes {H, T}. If you toss it twice, there are $2 \times 2 = 4$ outcomes {HH, HT, TH, TT}. If you toss it three times, there are $2 \times 2 \times 2 = 2^3 = 8$ outcomes {HHH, HHT, HTH, HTT, THH, THT, TTH, TTT}.

In general, if you toss a coin $n$ times, there are $2^n$ possible outcomes. (A decision algorithm for constructing the outcome when $n$ coins are tossed consists of $n$ steps, in each of which thre are two choices: H or T. So, the total number of possible outcomes is $2 \times 2 \times \cdots \times 2$ $n$ times).

Take $X$ to be the total number of heads that come up. First, the possible values of $X$ are $0, 1, 2, 3$. Now we calculate the probabilities for the probability distribution of $X$:
Event that $X = 0$ \t Event heads comes up 0 times \\ \gap[20] $=$ Set of all outcomes with no heads \\ \gap[20] = #[{TTT}][{ZZZ}]# \t The event that $X = 0$ consists of 1 outome. \\ \t !3! %25 A decision algorithm for constructing an outcome with 0 heads is as follows: Start with three empty slots representing the outcomes of the three coin tosses. Then select 0 slots out of the three to place the H. There are $C(3,0) = 1$ possible outcomes. (The rest of the slots automatically get Ts, so there are no further decisions.) \\ %Tf, $P(X = 0) = \dfrac{1}{8}$ \t 1 outome out of the total of 8 equally likely outcomes. \\   \\ Event that $X = 1$ \t Event heads comes up once \\ \gap[20] $=$ Set of all outcomes with 1 head \\ \gap[20] = #[{HTT, THT ,TTH}][{CZZ, ZCZ ,ZZC}]# \t The event that $X = 1$ consists of 3 outomes. \\ \t !3! %25 A decision algorithm for constructing an outcome with 1 head is as follows: Start with three empty slots representing the outcomes of the three coin tosses. Then select one slot out of the three to place the H. There are $C(3,1) = 3$ possible outcomes. (The rest of the slots automatically get Ts, so there are no further decisions.) \\ %Tf, $P(X = 1) = \dfrac{3}{8}$ \t 3 outomes out of the total of 8 equally likely outcomes. \\   \\ Event that $X = 2$ \t Event heads comes up twice \\ \gap[20] $=$ Set of all outcomes with 2 heads \\ \gap[20] = #[{HHT, HRH ,THH}][{CCZ, CAC ,ZCC}]# \t The event that $X = 2$ consists of 3 outomes. \\ \t !3! %25 A decision algorithm for constructing an outcome with 2 heads is as follows: Start with three empty slots representing the outcomes of the three coin tosses. Then select 2 slots out of the three to place the H. There are $C(3,2) = 3$ possible outcomes. (The rest of the slots automatically get Ts, so there are no further decisions.) \\ %Tf, $P(X = 2) = \dfrac{3}{8}$ \t 3 outomes out of the total of 8 equally likely outcomes. \\   \\ Event that $X = 3$ \t Event heads comes up three times \\ \gap[20] $=$ Set of all outcomes with 3 heads \\ \gap[20] = #[{HHH}][{CCC}]# \t The event that $X = 3$ consists of one outome. \\ \t !3! %25 A decision algorithm for constructing an outcome with 3 heads is as follows: Start with three empty slots representing the outcomes of the three coin tosses. Then select 3 slots out of the three to place the H. There are $C(3,3) = 1$ possible outcomes. \\ %Tf, $P(X = 3) = \dfrac{1}{8}$ \t 1 outome out of the total of 8 equally likely outcomes.
Now pretend you are tossing a coin %30 times. and take $X$ to be the total number of %33 that come up. There are then $2^{%30}=%32$ possible outcomes:
%31.

Take $X$ to be the total number of %33 that come up.
Now fill in the missing probabilities. %26

Using frequencies to obtain the probability distribution

Sometimes, we can only estimate the probability of each value of $X$ using relative frequencies. Recall that we obtain the relative frequency of an event by dividing its frequency by the total number of times the experiment is performed. (Would you like to review?) Here is an example:

A survey of randomly selected shopping malls yields the following data on the number of movie screens they contain: Movie screens \t 0 \t 1 \t 2 \t 3 \t 4 \t 5 \\ Number of malls \t %40 \t %41 \t %42 \t %43 \t %44 \t %45 Take $X$ to be the number of movie screens in a selected mall (so the values of $X$ are given in the top row of the chart). The frequencies are then the numbers in the second row. For instance, we observed $X = 0$ (no movie screens) a total of %40 times, as %40 of the malls had no movie screens. So, we rewrite the table as follows: $\bold{x}$ \t 0 \t 1 \t 2 \t 3 \t 4 \t 5 \\ Frequency \t %40 \t %41 \t %42 \t %43 \t %44 \t %45 Think of the survey as repetitions of an experiment in which a mall is selected at random (without replacement) and the value of $X$ is measured (the number of screens).

Now adjust the bar graph by dragging the top of each bar to the appropriate position.

Measurement classes?

The number of on-line Monday stock trades at OHaganStockTrades.com (a subsidiary of oHaganBooks.com) was measured for %57 Mondays in a row, with the following results: Stock trades \t 0−99 \t 100−199 \t 200−299 \t 300−399 \t 400−499 \\ Number of Mondays \t %50 \t %51 \t %52 \t %53 \t %54 Thus, for example, there were between 300 and 399 trades on %53 of the %57 Mondays. The measurement classes are the ranges 0−99, 100−299, etc.

We would like $X$ to measure the number of stock trades on a randomly selected Monday, and then calculate its probability distribution. Since we only have information for ranges of values, we replace each measurement class by its (rounded) midpoint. Let us take them one-by-one:
    The midpoint of the 0−99 range is $\dfrac{0+99}{2} = 59.5$, which we round to $50$.
    The midpoint of the 100−199 range is $\dfrac{100+199}{2} = 149.5$, which we round to $150$.
Now continue in the same way to obtain the remaining values of $X$: Stock trades \t 50 \t 150 \t 250 \t 350 \t 450 \\ Number of Mondays \t %50 \t %51 \t %52 \t %53 \t %54 Now use the above frequency table to complete the estimated probability distribution of $X$.
Now try the exercises in %4, some of the %8, or move ahead to the next tutorial by pressing "Next tutorial" on the sidebar.

Last Updated: November, 2018
Copyright © 2017

 

Preceding tutorial
Non-game version
Next tutorial 
All tutorials
Main page
Everything for calc
Everything for finite math
Everything
Español