Unit 4, lesson 25

Discrete Random Variables

What a random variable is, how one observed realization differs from its distribution, and when a random variable is discrete, with a finite or countably infinite support whose values need not be integers.

  • Video 25
  • Random Variables and Their Distributions

Two switches are tested, and each one either works or fails. You could record the full result for both switches, or only how many of them work. Both records describe the same experiment, but they answer different questions and keep different amounts of information. This lesson makes the second kind of record precise. A random variable is a fixed rule that turns each outcome into a number, and its distribution says how probability is spread over the numbers that rule can produce.

Key terms

Random variable

Definition Let Ω\Omega be the sample space of an experiment with probability PP. A random variable is a function XX that assigns a real number X(ω)X(\omega) to each outcome ω\omega in Ω\Omega. For a set BB of real numbers, the event {X∈B}\{X \in B\} is the set of outcomes

{ω∈Ω:X(ω)∈B}\{\omega \in \Omega : X(\omega) \in B\}

at which XX takes a value in BB. So expressions such as P(X=1)P(X = 1) or P(X≥1)P(X \ge 1) are probabilities of events in Ω\Omega. On a finite or countably infinite sample space in which every set of outcomes is an event, every real-valued function on Ω\Omega is a random variable. When not every set of outcomes is an event, which is typical on larger sample spaces, a technical condition called measurability is added so that these sets are events.

In plain words The rule itself is not random. What is uncertain before the experiment is which outcome will occur, and therefore which number the rule will produce.

Example Inspect switch one and then switch two, writing W for working and F for failed. The sample space has four ordered outcomes. In this constructed model each switch works with probability 12\tfrac{1}{2} and the two results are independent, so each outcome has probability 12⋅12=14\tfrac{1}{2} \cdot \tfrac{1}{2} = \tfrac{1}{4}. Let XX be the number of working switches.

OutcomeWWWFFWFF
Probability14\tfrac{1}{4}14\tfrac{1}{4}14\tfrac{1}{4}14\tfrac{1}{4}
Value of XX22111100

The event {X=1}\{X = 1\} is {WF,FW}\{\mathrm{WF}, \mathrm{FW}\}, so P(X=1)=14+14=12P(X = 1) = \tfrac{1}{4} + \tfrac{1}{4} = \tfrac{1}{2}. The event {X≥1}\{X \ge 1\} leaves out only FF, so P(X≥1)=1−14=34P(X \ge 1) = 1 - \tfrac{1}{4} = \tfrac{3}{4}.

Realization

Definition A realization of a random variable XX is the number X(ω)X(\omega) for the outcome ω\omega that actually occurs. A capital letter such as XX names the random variable, and a lowercase letter such as xx stands for a possible or observed value. The event {X=x}\{X = x\} is the set of outcomes at which the rule produces the number xx.

In plain words The random variable is the rule, and the realization is the number the rule gave this time. A single realization is one number. It does not say how likely that number was.

Example Suppose the test of the two switches produces WF. The realization of XX is then x=1x = 1. Another run might produce FF, with realization 00. Neither run changes the function XX or the model probabilities P(X=0)=14P(X = 0) = \tfrac{1}{4}, P(X=1)=12P(X = 1) = \tfrac{1}{2} and P(X=2)=14P(X = 2) = \tfrac{1}{4}. Notice also that the realization 11 does not reveal which switch works, because WF and FW give the same value.

Discrete random variable

Definition A random variable XX is discrete if there is a finite or countably infinite set SS of real numbers with P(X∈S)=1P(X \in S) = 1. A set is countably infinite when it is infinite and its elements can be listed as a sequence x1,x2,x3,…x_1, x_2, x_3, \dots in which every element appears. Every random variable on a finite or countably infinite sample space is discrete, because it takes at most countably many values. Whether the values are whole numbers plays no role.

In plain words With probability 11, a discrete random variable takes one of a list of values that can be written one after another, even when the list never ends. Fractions and negative numbers are allowed in that list.

Example Suppose each working switch earns half a token, and let Y=X/2Y = X/2. The possible values of YY are 00, 12\tfrac{1}{2} and 11. They are not all integers, but there are only three of them, so YY is discrete. By contrast, if a random variable gives probability 00 to every single real number, it cannot be discrete. For any finite or countably infinite set SS, countable additivity would give P(X∈S)P(X \in S) as a sum of zeros, which is 00 and not 11. Such variables appear later in the course.

Support

Definition The support of a discrete random variable XX is the set of values that have positive probability,

{x∈R:P(X=x)>0}.\{x \in \mathbb{R} : P(X = x) > 0\}.

It is finite or countably infinite, XX lies in it with probability 11, and every real number xx outside it has P(X=x)=0P(X = x) = 0. A countably infinite support is a support with infinitely many values, which can still be listed in a sequence.

In plain words The support lists the values that can actually turn up with positive probability. A countably infinite support cannot be written as a finite list, but its values can still be counted off one at a time.

Example For the two switches the support of XX is {0,1,2}\{0, 1, 2\}. The value 33 is outside it, since two switches cannot give three working switches, so P(X=3)=0P(X = 3) = 0. For a countably infinite support, toss a fair coin repeatedly with independent tosses, and let TT be the number of tosses up to and including the first head. On the one sequence with no head at all, set T=0T = 0, so that TT has a value at every outcome. The event {T=k}\{T = k\} means k−1k - 1 tails followed by a head, so independence gives

P(T=k)=(12)kP(T = k) = \left(\tfrac{1}{2}\right)^{k}

for every positive integer kk. The event that no head ever appears is contained in the event that the first nn tosses are all tails, so its probability is at most (12)n(\tfrac{1}{2})^{n} for every nn, which forces it to be 00. So the value chosen on that sequence affects no probability, and with probability 11 the value of TT is one of 1,2,3,…1, 2, 3, \dots. The support is the countably infinite set of positive integers. No finite list would do, because P(T>n)=(12)n>0P(T > n) = (\tfrac{1}{2})^{n} > 0 for every nn.

Distribution of a random variable

Definition The distribution of a random variable XX is the rule that gives the probability P(X∈B)P(X \in B) for each set BB of real numbers. For a discrete XX it is determined by the support together with the probabilities P(X=x)P(X = x) of its values, because the probability of any statement about XX is found by adding those probabilities over the support values that satisfy it. Two discrete random variables have the same distribution when they give every real number the same probability, even if they are different functions on Ω\Omega.

In plain words The distribution is the full pattern of chances before anything is observed. A realization is one number produced by a single run. Having the same distribution does not make two random variables the same.

Example The switch count XX has P(X=0)=14P(X = 0) = \tfrac{1}{4}, P(X=1)=12P(X = 1) = \tfrac{1}{2} and P(X=2)=14P(X = 2) = \tfrac{1}{4}. Its three values are not equally likely, because the value 11 has two outcomes behind it and the others have one each. Now let A1=1A_1 = 1 if switch one works and A1=0A_1 = 0 otherwise, and define A2A_2 in the same way for switch two. Then X=A1+A2X = A_1 + A_2 at every outcome. The variables A1A_1 and A2A_2 have the same distribution, each equal to 11 with probability 12\tfrac{1}{2} and 00 with probability 12\tfrac{1}{2}. They are still different random variables, since at the outcome WF the value of A1A_1 is 11 and the value of A2A_2 is 00.

Check yourself

  1. Three switches are tested, and each works with probability 12\tfrac{1}{2}, independently of the others. Let NN be the number of working switches. Find the support and the distribution of NN, and find P(N≥2)P(N \ge 2).
Show the answer

There are 23=82^3 = 8 ordered outcomes such as WWF, and by independence each has probability (12)3=18(\tfrac{1}{2})^3 = \tfrac{1}{8}. The numbers of outcomes with 00, 11, 22 and 33 working switches are 11, 33, 33 and 11. So the support is {0,1,2,3}\{0, 1, 2, 3\} and the distribution is

kk00112233
P(N=k)P(N = k)18\tfrac{1}{8}38\tfrac{3}{8}38\tfrac{3}{8}18\tfrac{1}{8}

The probabilities add to 88=1\tfrac{8}{8} = 1. The event {N≥2}\{N \ge 2\} contains WWF, WFW, FWW and WWW, so P(N≥2)=48=12P(N \ge 2) = \tfrac{4}{8} = \tfrac{1}{2}.

  1. A classmate says that NN has four possible values, so each value has probability 14\tfrac{1}{4}. Explain the mistake. Then suppose you are told only that the realization of NN is 22. What can you say about which switch failed?
Show the answer

The probabilities of the values come from the outcomes behind them, not from the number of values. The value 11 is produced by three of the eight equally likely outcomes, so its probability is 38\tfrac{3}{8}, while the value 00 is produced by only FFF and has probability 18\tfrac{1}{8}.

The realization 22 is consistent with WWF, WFW and FWW, so the failed switch could be any of the three. In this model each of those outcomes has conditional probability 1/83/8=13\tfrac{1/8}{3/8} = \tfrac{1}{3} given N=2N = 2. The count records how many switches work and forgets which ones.

  1. With three switches as above, let A1=1A_1 = 1 if switch one works and A1=0A_1 = 0 otherwise, and define A3A_3 in the same way for switch three. Do A1A_1 and A3A_3 have the same distribution? Are they the same random variable?
Show the answer

Switch one works in 44 of the 88 equally likely outcomes, so P(A1=1)=12P(A_1 = 1) = \tfrac{1}{2} and P(A1=0)=12P(A_1 = 0) = \tfrac{1}{2}. The same count holds for switch three, so the two variables have the same distribution.

They are not the same random variable. At the outcome WWF the value of A1A_1 is 11 and the value of A3A_3 is 00. In fact the two values differ in the 44 outcomes where switches one and three disagree, so P(A1≠A3)=12P(A_1 \ne A_3) = \tfrac{1}{2}.

How this lesson connects