Skip to content

Unit 2: Probability, Random Variables, and Probability Distributions

Introduction to Random Variables and Probability Distributions

Define a discrete random variable, build its probability distribution from probability rules or a simulation, and read and use its cumulative distribution.

Topic 2.8 · 8 min read

A food truck owner can't know how many drinks the next customer will order, but over thousands of orders a pattern is steady: 30% of orders have no drink, 45% have one, 15% have two, and 10% have three. A list like that, every possible number paired with its probability, is a probability distribution, and it's the object the rest of Unit 2 works with.

Random variables

A random variable is a numerical value determined by the outcome of a random process. Before the process runs, you don't know its value; afterward, the outcome fixes it. Random variables get capital letters, like XX, and a particular value gets the lowercase letter, like xx. So "X=2X = 2" is the event that the random variable comes out to 2, and P(X=2)P(X = 2) is its probability.

The definition has two parts that matter. The value must be a number: "the color of the next car" comes from a random process but isn't a random variable, while "the number of red cars among the next 10" is. And the number must come from chance: the number of days in March is always 31, so it isn't random.

A discrete random variable has values you can list with gaps between them, usually counts: the number of drinks in an order, the number of heads in 5 flips, the number of defective chips in a box. A random variable that can take any value in an interval, like the time until the next customer arrives, is continuous; topic 2.11 handles that kind. This topic is about discrete random variables.

Probability distributions

The probability distribution of a discrete random variable gives the probability of each of its possible values. Let XX = the number of drinks in a randomly selected order from the food truck:

xx0123
P(X=x)P(X = x)0.300.450.150.10

Two requirements make a table like this a valid distribution, and both come straight from topic 2.4:

Here 0.30+0.45+0.15+0.10=10.30 + 0.45 + 0.15 + 0.10 = 1, so the table is valid. The second requirement also lets you find one missing probability: if a table left out P(X=3)P(X = 3), it would have to be 1−(0.30+0.45+0.15)=0.101 - (0.30 + 0.45 + 0.15) = 0.10.

To find the probability of an event about XX, add the probabilities of the values in it, because the values are mutually exclusive. "At least two drinks" is X≥2X \ge 2:

P(X≥2)=P(X=2)+P(X=3)=0.15+0.10=0.25.P(X \ge 2) = P(X = 2) + P(X = 3) = 0.15 + 0.10 = 0.25.

With a discrete variable, the inequality sign changes the answer. P(X>2)P(X > 2) leaves out the value 2, so it's only 0.100.10.

Three ways to show a distribution

A table, like the one above, lists each value and its probability.

A graph, usually a probability histogram, puts the values on the horizontal axis and draws a bar over each one whose height is its probability.

Probability histogram of X, the number of drinks in a food-truck order. Bars centered at 0, 1, 2 and 3 have heights 0.30, 0.45, 0.15 and 0.10. The vertical axis is probability from 0 to 0.5. The distribution peaks at 1 and is skewed right.

Shape, center and spread are read from it the same way as for a histogram of data (topic 1.6): this distribution peaks at 1 drink and is skewed right, with a tail toward 3.

A function gives the probability as a formula in xx. You'll see one in the next section.

Building a distribution from probability rules

When the random process is simple enough to list its outcomes, you can work the distribution out exactly. Roll two fair four-sided dice (faces 1 to 4) and let XX = the larger of the two numbers (if they match, that number). There are 4×4=164 \times 4 = 16 equally likely outcomes. Sort them by the value of XX:

  • X=1X = 1: only (1, 1). Probability 116\frac{1}{16}.
  • X=2X = 2: (1, 2), (2, 1), (2, 2). Probability 316\frac{3}{16}.
  • X=3X = 3: (1, 3), (2, 3), (3, 3), (3, 1), (3, 2). Probability 516\frac{5}{16}.
  • X=4X = 4: the 7 outcomes with at least one 4. Probability 716\frac{7}{16}.

The probabilities sum to 1616=1\frac{16}{16} = 1. The pattern has a reason: X≤kX \le k means both dice are at most kk, which happens in k2k^2 outcomes, so X=kX = k exactly accounts for k2−(k−1)2=2k−1k^2 - (k-1)^2 = 2k - 1 outcomes. That gives the distribution as a function:

P(X=x)=2x−116,x=1,2,3,4.P(X = x) = \frac{2x - 1}{16}, \qquad x = 1, 2, 3, 4.

The steps are always the same: list the sample space, find the value of XX for each outcome, and add the probabilities of the outcomes that give each value. When outcomes aren't equally likely, use the multiplication and addition rules from topics 2.6 and 2.7 to get each probability.

Estimating a distribution by simulation

Some processes are tedious to work out exactly. A simulation (topic 2.3) estimates the distribution instead: run the process many times with random numbers, record the value of XX in each trial, and use the relative frequency of each value as its estimated probability. More trials give estimates that tend to be closer to the true probabilities.

Cumulative distributions

A cumulative probability distribution gives, for each value xx, the probability that XX is less than or equal to xx: P(X≤x)P(X \le x). Build it by keeping a running total down the table. For the food truck:

xx0123
P(X=x)P(X = x)0.300.450.150.10
P(X≤x)P(X \le x)0.300.750.901.00

The cumulative column never decreases and ends at exactly 1, because every value of XX is at most the largest one. It answers "at most" questions in one look: P(X≤1)=0.75P(X \le 1) = 0.75, so three quarters of orders have at most one drink. With the complement rule it answers "more than" questions too, P(X>1)=1−P(X≤1)=0.25P(X > 1) = 1 - P(X \le 1) = 0.25, and differences of cumulative values give ranges: P(1≤X≤2)=P(X≤2)−P(X≤0)=0.90−0.30=0.60P(1 \le X \le 2) = P(X \le 2) - P(X \le 0) = 0.90 - 0.30 = 0.60.

For the dice maximum, the cumulative distribution is also a function: P(X≤x)=x216P(X \le x) = \frac{x^2}{16} for x=1,2,3,4x = 1, 2, 3, 4, which is the k2k^2 count from before.

Worked examples

Worked exampleExample 1: a missing probability

A hotel finds that the number of nights XX a randomly selected guest stays has this distribution.

xx12345
P(X=x)P(X = x)0.250.35kk0.120.08

(a) Find kk. (b) Find the probability a guest stays at least 3 nights. (c) Find P(2≤X<4)P(2 \le X < 4).

Show solution

(a) The probabilities must add to 1: 0.25+0.35+k+0.12+0.08=10.25 + 0.35 + k + 0.12 + 0.08 = 1, so 0.80+k=10.80 + k = 1 and k=0.20k = 0.20.

(b) "At least 3" includes 3: P(X≥3)=0.20+0.12+0.08=0.40P(X \ge 3) = 0.20 + 0.12 + 0.08 = 0.40.

(c) The values with 2≤x<42 \le x < 4 are 2 and 3 (4 is excluded by the strict sign): P(2≤X<4)=0.35+0.20=0.55P(2 \le X < 4) = 0.35 + 0.20 = 0.55.

Worked exampleExample 2: estimating with a simulation

A cereal brand puts one of three toys in each box, each equally likely, independently from box to box. A family buys 4 boxes. Let XX = the number of different toys they get. A student simulates this 200 times: in each trial, a calculator generates 4 random integers from 1 to 3 (one per box, the integer naming the toy), and the student records how many different integers appear. The results:

Different toys123
Number of trials710588

Estimate the probability distribution of XX, and estimate the probability that the family gets all three toys.

Show solution

Divide each count by the 200 trials:

xx123
Estimated P(X=x)P(X = x)0.0350.5250.440

The estimates add to 11, as they must. The estimated probability of getting all three toys is P(X=3)≈0.44P(X = 3) \approx 0.44.

Each trial matches the real process: 4 boxes, each with an equally likely toy from 3, chosen independently. That's what makes the relative frequencies estimates of the true probabilities. Counting outcomes exactly gives P(X=3)=3681≈0.444P(X = 3) = \frac{36}{81} \approx 0.444, so 200 trials came close. A different 200 trials would give somewhat different estimates.

Worked exampleExample 3: exam-style free response

A student applies to three summer programs. The probabilities of acceptance are 0.6 for the first, 0.4 for the second, and 0.2 for the third, and the decisions are independent. Let XX = the number of programs that accept the student.

(a) Construct the probability distribution of XX.

(b) Construct the cumulative probability distribution of XX.

(c) Find the probability that the student is accepted to at least one program.

Show solution

(a) XX can be 0, 1, 2 or 3. The rejection probabilities are 0.40.4, 0.60.6 and 0.80.8. Because the decisions are independent, the probability of any particular combination is a product (topic 2.7), and the combinations giving the same XX are mutually exclusive, so their probabilities add. Each product below lists the first, second and third program in that order.

P(X=0)=(0.4)(0.6)(0.8)=0.192P(X = 0) = (0.4)(0.6)(0.8) = 0.192
P(X=1)=(0.6)(0.6)(0.8)+(0.4)(0.4)(0.8)+(0.4)(0.6)(0.2)=0.288+0.128+0.048=0.464P(X = 1) = (0.6)(0.6)(0.8) + (0.4)(0.4)(0.8) + (0.4)(0.6)(0.2) = 0.288 + 0.128 + 0.048 = 0.464
P(X=2)=(0.6)(0.4)(0.8)+(0.6)(0.6)(0.2)+(0.4)(0.4)(0.2)=0.192+0.072+0.032=0.296P(X = 2) = (0.6)(0.4)(0.8) + (0.6)(0.6)(0.2) + (0.4)(0.4)(0.2) = 0.192 + 0.072 + 0.032 = 0.296
P(X=3)=(0.6)(0.4)(0.2)=0.048P(X = 3) = (0.6)(0.4)(0.2) = 0.048

For X=1X = 1, the three terms are accepted by only the first, only the second, only the third. For X=2X = 2, they are rejected by only the third, only the second, only the first.

xx0123
P(X=x)P(X = x)0.1920.4640.2960.048

Check: 0.192+0.464+0.296+0.048=10.192 + 0.464 + 0.296 + 0.048 = 1.

(b) Running totals:

xx0123
P(X≤x)P(X \le x)0.1920.6560.9521.000

(c) P(X≥1)=1−P(X=0)=1−0.192=0.808P(X \ge 1) = 1 - P(X = 0) = 1 - 0.192 = 0.808. The probability that the student is accepted to at least one of the three summer programs is 0.808.

Why these moves: listing each combination with its product shows the grader exactly where every probability comes from, and the sum-to-1 check catches a missed combination. Part (c) uses the complement because "at least one" is three values but "none" is one. This is not a binomial setting (topic 2.10), because the three acceptance probabilities differ.

Where students lose points

Check yourself

  1. Question 1

    Which of the following is a discrete random variable?

    1. A

      The color of a randomly selected car in a parking lot

    2. B

      The number of siblings a randomly selected student has

    3. C

      The time a randomly selected runner takes to finish a 5-kilometer race

    4. D

      The name of the team that wins a randomly chosen game

    Show answer

    B

    A number of siblings is a numerical outcome of a random selection, and its values (0, 1, 2, ...) can be listed with gaps between them. Choice C is a random variable too, but time can take any value in an interval, so it is continuous; A and D are not numerical at all.

  2. Question 2

    Which table gives a valid probability distribution for a random variable with values 0, 1, 2, 3?

    1. A

      0.2, 0.3, 0.4, 0.20.2,\ 0.3,\ 0.4,\ 0.2

    2. B

      0.5, −0.1, 0.3, 0.30.5,\ -0.1,\ 0.3,\ 0.3

    3. C

      0.1, 0.25, 0.4, 0.250.1,\ 0.25,\ 0.4,\ 0.25

    4. D

      0.25, 0.25, 0.250.25,\ 0.25,\ 0.25 (no probability listed for 3)

    Show answer

    C

    C's probabilities are each between 0 and 1 and add to exactly 1. A adds to 1.1; B adds to 1 but includes a negative probability, which is impossible; D leaves out a value and adds to only 0.75.

  3. Question 3

    The cumulative distribution of a random variable XX is P(X≤0)=0.15P(X \le 0) = 0.15, P(X≤1)=0.50P(X \le 1) = 0.50, P(X≤2)=0.85P(X \le 2) = 0.85, P(X≤3)=1P(X \le 3) = 1. Find P(X=2)P(X = 2) and P(X≥2)P(X \ge 2).

    Show answer

    P(X=2)=0.85−0.50=0.35P(X = 2) = 0.85 - 0.50 = 0.35 and P(X≥2)=1−0.50=0.50P(X \ge 2) = 1 - 0.50 = 0.50.

    A single value's probability is the jump in the cumulative distribution at that value. "At least 2" is the complement of "at most 1," whose probability is the cumulative value at 1.

  4. Question 4

    A random variable has P(X=x)=x15P(X = x) = \frac{x}{15} for x=1,2,3,4,5x = 1, 2, 3, 4, 5. Show that this is a valid distribution and find P(X≥4)P(X \ge 4).

    Show answer

    Each x15\frac{x}{15} is between 0 and 1, and 1+2+3+4+515=1515=1\frac{1 + 2 + 3 + 4 + 5}{15} = \frac{15}{15} = 1. P(X≥4)=415+515=915=0.6P(X \ge 4) = \frac{4}{15} + \frac{5}{15} = \frac{9}{15} = 0.6.

    A function is a valid distribution under the same two requirements as a table. Adding the probabilities of the values 4 and 5 gives the event "at least 4."

Go deeper