math.wiki
Probability › Random variables › Random variables and probability distributions
Open on the map
Statistics · S.MD.A.1 · S.MD.A.3

Random variables and probability distributions

A coffee shop pours drinks with zero, one, two, three or four shots of espresso. How do you write down, all at once, how likely each number of shots is, and what can you read off once you have?

Where you are 11 in Random variables

When you reach for it

A probability model lists the outcomes of a chance process with a probability for each, every probability between 0 and 1 and all of them adding to 1. Many questions, though, are not about the outcome itself but about a number that comes with it. Sopio runs a coffee shop. When a customer walks in, she does not care which drink they order so much as how many shots of espresso it takes, because that number decides how fast her beans run out.

Reach for a random variable and its distribution whenever the thing you care about is a number that depends on chance: the shots in the next drink, the larger of two numbers drawn from a jar, the sum of two draws. The distribution puts every possible value and its probability side by side, so that any question about the variable (“at least two shots?”) becomes a matter of adding entries.

This lesson runs over two days. Part 1 defines a random variable, writes its distribution as a table, checks that the table is valid, and answers questions by adding. Part 2 builds a distribution from a sample space, writes it as a function, and draws it as a probability histogram.

The procedure

Part 1: random variables and the distribution table

A random variable is a rule that gives a number to each outcome of a chance process. It is written with a capital letter, such as X, and a particular value it can take is written in lowercase, such as x. “Let X be the number of espresso shots in the drink of a randomly chosen customer” names the variable; x = 2 is one value it can take. The variable is a function in the sense of a function: each outcome (a customer’s order) gets exactly one number.

A discrete random variable has values you can list, usually because they come from counting: shots, customers in line, pastries in an order. A variable whose values fill a whole interval, because they come from measuring (the temperature of a drink, the time a customer waits), is continuous; its probabilities are handled differently, in Continuous random variables and density curves. This lesson is about discrete variables only.

The probability distribution of a discrete random variable lists every value it can take with the probability of that value. Mzia keeps records at the shop and settles on these (made-up) figures for X, the number of shots:

x01234
P(X = x)0.150.400.250.150.05

The top row holds the values, the bottom row their probabilities. Read a column as a sentence: “the probability that a randomly chosen drink has exactly 2 shots is 0.25.”

Why a valid table must pass two tests. Each entry P(X = x) is the probability of an event (the outcomes that give the value x), so, like every probability, it lies between 0 and 1. And the events “X = 0”, “X = 1”, and so on cannot happen together (a drink has one number of shots) and between them cover every outcome (every drink has some number of shots from the list). So their probabilities add to the probability of the whole sample space, which is 1:

\begin{aligned} &0 \le P(X = x) \le 1 \text{ for every } x, \\ &\textstyle\sum P(X = x) = 1. \end{aligned}

For the shots, 0.15 + 0.40 + 0.25 + 0.15 + 0.05 = 1.00, and every entry lies between 0 and 1, so the table is valid. The same sum rule finds a missing entry: whatever the listed probabilities leave short of 1 belongs to the missing value.

Events by adding. An event such as “at least 2 shots” is written X \ge 2. It happens exactly when X is 2, 3 or 4, and those values cannot happen together, so the probability is the sum of their entries. When the event has many values and its opposite has few, the complement rule is quicker: P(X \ge 2) = 1 - P(X \le 1). Adding up from the left end (“at most x”) is called a cumulative probability, the subject of Cumulative probability.

Part 2: building, writing as a function, and drawing

Building a distribution from a sample space. When the outcomes of a process are equally likely, list the sample space, write the value of the variable beside each outcome, and count. The probability of a value is the number of outcomes giving it over the number of outcomes in all. Two different variables on the same sample space usually have different distributions, so always say which number the variable records.

The distribution as a function. Because each value x gets exactly one probability, the distribution is itself a function of x, written in Function notation as P(X = x) or sometimes p(x). Sometimes a single formula gives every entry, such as P(X = x) = \dfrac{x}{10} for x = 1, 2, 3, 4. A formula must come with its list of values, and it is valid only if every value it produces lies between 0 and 1 and the values add to 1.

The probability histogram. Draw the distribution like a histogram: a bar for each value, centered on the value and one unit wide, whose height is the probability. Because each bar is one unit wide, its area equals its height, so the areas of all the bars add to 1. The shape reads the same way as the shape of a data set: a peak, a tail, symmetry or skew.

0 0.15 1 0.40 2 0.25 3 0.15 4 0.05 0 0.10 0.20 0.30 0.40
P(X = x)
Number of espresso shots, x
Figure 1The distribution of the number of espresso shots (made-up data). Each bar’s height is the probability of the value under it.

Worked examples

Examples 1 to 4 belong to Part 1 and Examples 5 to 7 to Part 2.

Example 1

Reading the espresso table

Use the table of X, the number of espresso shots in a randomly chosen drink. Check that the table is valid, then find P(X \ge 2), P(X \le 1) and P(1 \le X \le 3), and say what the first means.

Solution

Every entry lies between 0 and 1, and 0.15 + 0.40 + 0.25 + 0.15 + 0.05 = 1.00, so the table is a valid distribution.

“At least 2” means X = 2, 3 or 4. These values exclude one another, so their probabilities add: P(X \ge 2) = 0.25 + 0.15 + 0.05 = 0.45. In context: 45\% of the shop’s drinks, over the long run, take two or more shots.

“At most 1” is the complement of “at least 2”, since every drink has either at most one shot or at least two, never both. So P(X \le 1) = 1 - 0.45 = 0.55. Check by adding directly: 0.15 + 0.40 = 0.55.

“Between 1 and 3 inclusive” keeps the end values: P(1 \le X \le 3) = 0.40 + 0.25 + 0.15 = 0.80.

Example 2

Which tables are valid?

Nodar, who works the register, proposes three tables for Y, the number of pastries in a randomly chosen order. Which could be a probability distribution?

y0123
Table A0.500.300.150.10
Table B0.600.350.10-0.05
Table C0.450.350.150.05
Solution

Table A: every entry is between 0 and 1, but 0.50 + 0.30 + 0.15 + 0.10 = 1.05. The values 0 to 3 cover every order and exclude one another, so their probabilities must add to exactly 1. Not valid.

Table B: the entries add to 0.60 + 0.35 + 0.10 - 0.05 = 1.00, but P(Y = 3) = -0.05 is negative, and no probability can be. Not valid; a correct sum is not enough.

Table C: every entry lies between 0 and 1 and 0.45 + 0.35 + 0.15 + 0.05 = 1.00. Valid.

Example 3

A missing probability

Mzia’s records give N, the number of drinks in a randomly chosen order, as below, with one entry smudged. Find p, then find P(N \ge 3).

n12345
P(N = n)0.350.22p0.120.06
Solution

The five values cover every order and exclude one another, so the entries add to 1:

\begin{aligned} 0.35 + 0.22 + p + 0.12 + 0.06 &= 1 \\ 0.75 + p &= 1 \\ p &= 0.25. \end{aligned}

The value 0.25 lies between 0 and 1, so the completed table is valid. Then P(N \ge 3) = 0.25 + 0.12 + 0.06 = 0.43. By the complement, 1 - (0.35 + 0.22) = 0.43 as well.

Example 4

Two unknowns tied together

Let G be the number of pumps of flavor syrup in a randomly chosen drink. Sopio knows that P(G = 0) = 0.10 and P(G = 3) = 0.30, and that two pumps are exactly twice as likely as one. Find the distribution and P(G > 1).

Solution

Write P(G = 1) = k; then P(G = 2) = 2k. The four entries add to 1:

\begin{aligned} 0.10 + k + 2k + 0.30 &= 1 \\ 3k &= 0.60 \\ k &= 0.20. \end{aligned}

So P(G = 1) = 0.20 and P(G = 2) = 0.40, both between 0 and 1. The distribution is 0.10, 0.20, 0.40, 0.30 for g = 0, 1, 2, 3. “More than 1” means 2 or 3: P(G > 1) = 0.40 + 0.30 = 0.70.

Example 5

The larger of two tokens

To pick a free add-in, a customer draws two tokens at random, without replacement, from a jar holding tokens numbered 1, 2, 3 and 4. Let L be the larger of the two numbers. Find the distribution of L, write it as a function, and find P(L \ge 3).

Solution

The order of the draw does not matter for the larger number, so list the unordered pairs. Each of the 6 pairs is equally likely, because the draw is random. Write L beside each:

PairLPairL
\{1,2\}2\{2,3\}3
\{1,3\}3\{2,4\}4
\{1,4\}4\{3,4\}4

The value 1 never appears: the larger of two different tokens is at least 2. Counting,

x234
P(L = x)\displaystyle \frac{1}{6}\displaystyle \frac{2}{6}\displaystyle \frac{3}{6}

The numerators run 1, 2, 3, one less than x, so P(L = x) = \dfrac{x - 1}{6} for x = 2, 3, 4. Every value lies between 0 and 1, and \displaystyle \frac{1 + 2 + 3}{6} = 1, so the function is a valid distribution. Finally \displaystyle P(L \ge 3) = \frac{2}{6} + \frac{3}{6} = \frac{5}{6}.

Example 6

A distribution given by a formula

A made-up model for T, the number of tries a new employee needs to pour a latte with a clean pattern, is P(T = t) = c(5 - t) for t = 1, 2, 3, 4. Find c, write out the table, and find P(T \le 2).

Solution

The four probabilities must add to 1:

\begin{aligned} c(4) + c(3) + c(2) + c(1) &= 1 \\ 10c &= 1 \\ c &= \frac{1}{10}. \end{aligned}

The table is P(T = 1) = 0.4, P(T = 2) = 0.3, P(T = 3) = 0.2, P(T = 4) = 0.1, every entry between 0 and 1. The formula says each extra try is less likely than the one before. Then P(T \le 2) = 0.4 + 0.3 = 0.7.

Example 7

The sum of two draws, and two shapes

A second jar holds tokens marked 0, 1 and 2. A customer draws one, puts it back, and draws again. Let S be the sum of the two numbers. Find the distribution of S as a table and as a function, then compare its probability histogram with that of L from Example 5.

Solution

With replacement, the draws are ordered pairs, and each of the 3 \times 3 = 9 pairs is equally likely. The sums are

second 0second 1second 2
first 0012
first 1123
first 2234

Each sum sits on a diagonal of the grid, and counting each one gives

s01234
P(S = s)\displaystyle \frac{1}{9}\displaystyle \frac{2}{9}\displaystyle \frac{3}{9}\displaystyle \frac{2}{9}\displaystyle \frac{1}{9}

The numerators climb by one to 3 at s = 2 and fall back by one, losing one for each step away from 2. So P(S = s) = \dfrac{3 - |s - 2|}{9} for s = 0, 1, 2, 3, 4. The numerators add to 9, so the total is 1.

2
\displaystyle \frac{1}{6}
3
\displaystyle \frac{2}{6}
4
\displaystyle \frac{3}{6}
0 0.10 0.20 0.30 0.40 0.50
P(L = x)
Larger token, L Value of L 0
\displaystyle \frac{1}{9}
1
\displaystyle \frac{2}{9}
2
\displaystyle \frac{3}{9}
3
\displaystyle \frac{2}{9}
4
\displaystyle \frac{1}{9}
0 0.10 0.20 0.30 0.40 0.50
P(S = x)
Sum, S Value of S
Figure 2Two random variables built from equally likely outcomes. The larger token piles up on the right; the sum is symmetric about 2.

The histogram of S is symmetric about 2, with a single peak in the middle: a sum near the middle can be made in more ways than a sum at either end. The histogram of L is skewed to the left: its tallest bar is at the top value 4, and the bars step down toward the smaller values, because a large token is in many pairs. The espresso histogram is skewed to the right, with its peak at 1 and a tail toward 4.

Boundaries

  • Everything here is for a discrete random variable, whose values can be listed. A measured variable such as a waiting time takes every value in an interval, any single value has probability 0, and probability becomes area under a curve; see Continuous random variables and density curves.
  • Adding entries to find an event’s probability works because the values of X exclude one another. It is the addition rule for disjoint events and needs nothing more.
  • Counting outcomes (Examples 5 and 7) needs the outcomes of the sample space to be equally likely. The values of the variable usually are not, as both examples show.
  • A formula P(X = x) defines a distribution only together with its list of values, and only if every value it gives is in [0, 1] and they add to 1.
  • A distribution made from records, like the espresso table, is a model. It describes the long run of many customers, not what the next customer will order.

Where this goes next

A distribution holds everything about a discrete random variable, and the next lessons summarize it. Cumulative probability adds entries cumulatively to answer “at most” and “between” questions quickly. Expected value finds the long-run average value, weighting each value by its probability, and Variance and standard deviation of a random variable measures the spread around it. Some distributions recur so often that they have a formula of their own, such as the The binomial distribution, and the probability histogram, once the bars shrink to nothing, turns into the density curve of Continuous random variables and density curves.

Exercises

Part 1: random variables and valid tables

  1. Say whether each random variable is discrete or continuous, and why: (a) the number of customers in line at 8 a.m.; (b) the time a customer waits for a drink; (c) the weight of a bag of coffee beans; (d) the number of muffins sold in a day.
  2. Which of these could be the distribution of a variable W with values 0, 1, 2? (a) 0.2, 0.5, 0.4; (b) 0.25, 0.75, 0; (c) 1.2, -0.1, -0.1.

Part 1: missing probabilities and events

Exercises 3 to 6 use K, the number of people in a group that walks in together:

k1234
P(K = k)0.420.31p0.07
  1. Find p.
  2. Find P(K \ge 2) and say what it means.
  3. Find P(K \le 3) using the complement.
  4. Find the probability that a group has an odd number of people.
  5. A variable takes the values 1 to 5 with P(1) = 0.05, P(2) = a, P(3) = a, P(4) = 0.25 and P(5) = 0.30. Find a and the probability that the variable is at least 3.
  6. A random variable X takes the values 0, 1, 2, 3, which have probabilities k, 3k, 4k and 2k. Find k and P(X \ge 2).
  7. Using the espresso table, find P(X > 2) and P(X \ne 1).
  8. Nodar says the probability that a drink has at least one shot of espresso is 0.80. Use the espresso table to check his claim.

Part 2: building distributions from a sample space

  1. Two tokens are drawn without replacement from the jar of tokens 1 to 4. Find the distribution of Y, the smaller number, as a table and as a function.
  2. For the same draw, let D be the larger number minus the smaller. Find the distribution of D and P(D \ge 2).
  3. Two draws are made with replacement from tokens 1, 2, 3. Find the distribution of M, the larger of the two numbers (when the two draws match, M is that number), and a formula for P(M = m).
  4. Two draws are made with replacement from tokens 0, 1, 2. Find the distribution of R, the product of the two numbers.

Part 2: distributions as functions

  1. Is P(X = x) = \dfrac{x}{15} for x = 1, 2, 3, 4, 5 a valid distribution? If so, find P(X \ge 4).
  2. Find c so that P(X = x) = cx^2 for x = 1, 2, 3 is a valid distribution, and find P(X = 3).
  3. Mzia proposes P(X = x) = \dfrac{x - 1}{5} for x = 0, 1, 2, 3, 4. Is it a valid distribution?

Part 2: probability histograms

1 2 3 4 5 0 0.05 0.10 0.15 0.20 0.25 0.30 0.35 0.40
P(V = v)
Rating, v
Figure 3For Exercises 18 and 19. The ratings of a randomly chosen customer (made-up data).
  1. Read the histogram of V, a customer’s rating. Find P(V \ge 4), P(V \le 2) and the most likely rating.
  2. Describe the shape of the histogram of V, and say what it tells Sopio about her customers.
  3. Sketch the probability histogram of Y from Exercise 11 and describe its shape. How is it related to the histogram of L?

Reasoning

  1. Explain why the probabilities in a distribution table must add to exactly 1, using what the columns stand for.
  2. Mzia says: “The shots variable has five values, so each has probability \displaystyle \frac{1}{5}.” Explain what is wrong, with an example from this lesson where equally likely outcomes give values that are not equally likely.
  3. Explain why the bars of a probability histogram, drawn one unit wide, have a total area of 1.
  4. The table in Exercise 14 has no column for 3. Is the table still complete? Would adding a column for 3 change anything?
Answers
  1. (a) Discrete: a count, values 0, 1, 2, \ldots (b) Continuous: a measured time can be any value in an interval. (c) Continuous: a measured weight. (d) Discrete: a count.
  2. (a) Not valid: 0.2 + 0.5 + 0.4 = 1.1. (b) Valid: entries in [0, 1] and the sum is 1; a probability of 0 is allowed. (c) Not valid: the sum is 1, but 1.2 > 1 and -0.1 < 0.
  3. p = 0.20, since 0.42 + 0.31 + 0.07 = 0.80 and the total must be 1.
  4. P(K \ge 2) = 0.31 + 0.20 + 0.07 = 0.58: in the long run, 58\% of groups have two or more people.
  5. P(K \le 3) = 1 - P(K = 4) = 1 - 0.07 = 0.93.
  6. Odd means K = 1 or K = 3: 0.42 + 0.20 = 0.62.
  7. 0.05 + 2a + 0.25 + 0.30 = 1 gives 2a = 0.40, so a = 0.20. Then P(\text{at least } 3) = 0.20 + 0.25 + 0.30 = 0.75.
  8. k + 3k + 4k + 2k = 10k = 1, so k = 0.1. Then P(X \ge 2) = 0.4 + 0.2 = 0.6.
  9. P(X > 2) = 0.15 + 0.05 = 0.20. P(X \ne 1) = 1 - 0.40 = 0.60.
  10. He is wrong: P(X \ge 1) = 1 - P(X = 0) = 1 - 0.15 = 0.85, not 0.80.
  11. Of the 6 pairs, the smaller number is 1 in three, 2 in two, 3 in one: \displaystyle P(Y = 1) = \frac{3}{6}, \displaystyle P(Y = 2) = \frac{2}{6}, \displaystyle P(Y = 3) = \frac{1}{6}, so P(Y = y) = \dfrac{4 - y}{6} for y = 1, 2, 3.
  12. Differences: \{1,2\}, \{2,3\}, \{3,4\} give 1; \{1,3\}, \{2,4\} give 2; \{1,4\} gives 3. So \displaystyle P(D = 1) = \frac{3}{6}, \displaystyle P(D = 2) = \frac{2}{6}, \displaystyle P(D = 3) = \frac{1}{6}, and \displaystyle P(D \ge 2) = \frac{3}{6} = \frac{1}{2}.
  13. Of the 9 ordered pairs, the larger is 1 only for (1,1), 2 for three pairs, 3 for five: \displaystyle P(M = 1) = \frac{1}{9}, \displaystyle P(M = 2) = \frac{3}{9}, \displaystyle P(M = 3) = \frac{5}{9}, so P(M = m) = \dfrac{2m - 1}{9} for m = 1, 2, 3.
  14. Of the 9 ordered pairs, five contain a 0 and give product 0; (1,1) gives 1; (1,2) and (2,1) give 2; (2,2) gives 4. So \displaystyle P(R = 0) = \frac{5}{9}, \displaystyle P(R = 1) = \frac{1}{9}, \displaystyle P(R = 2) = \frac{2}{9}, \displaystyle P(R = 4) = \frac{1}{9}.
  15. Yes: the entries \displaystyle \frac{1}{15} to \displaystyle \frac{5}{15} are in [0, 1] and add to \displaystyle \frac{15}{15} = 1. \displaystyle P(X \ge 4) = \frac{4 + 5}{15} = \frac{3}{5}.
  16. c(1 + 4 + 9) = 14c = 1, so \displaystyle c = \frac{1}{14}, and \displaystyle P(X = 3) = \frac{9}{14}.
  17. No. The values add to \displaystyle \frac{-1 + 0 + 1 + 2 + 3}{5} = 1, but \displaystyle P(X = 0) = -\frac{1}{5} is negative.
  18. P(V \ge 4) = 0.30 + 0.35 = 0.65; P(V \le 2) = 0.05 + 0.10 = 0.15; the most likely rating is 5, with probability 0.35.
  19. Skewed to the left: the bars rise toward the top rating, with a short tail toward 1. Most customers rate the shop high and few rate it low.
  20. Bars at 1, 2, 3 of heights \displaystyle \frac{3}{6}, \frac{2}{6}, \frac{1}{6}: skewed to the right, tallest at 1. It is the histogram of L flipped end to end: relabeling every token x as 5 - x turns the larger number of a pair into the smaller, so P(Y = y) = P(L = 5 - y).
  21. Each column is the event “X equals this value”. These events cannot happen together and together cover every outcome, so their probabilities add to the probability of the whole sample space, 1.
  22. The values of a variable need not be equally likely, even when the outcomes are. In Example 7 the nine draws are equally likely, but S = 2 comes from three of them and S = 0 from one, so \displaystyle P(S = 2) = \frac{3}{9} while \displaystyle P(S = 0) = \frac{1}{9}. The espresso table gives 0.40 to one shot, not \displaystyle \frac{1}{5}.
  23. A bar one unit wide has area width times height, 1 \times P(X = x) = P(X = x). So the total area is the sum of the probabilities, which is 1.
  24. Yes, complete: no outcome has product 3 (only 1 \times 3 or 3 \times 1 would, and there is no token 3), and the listed entries already add to 1. A column for 3 would hold 0 and change nothing.
kg1128 · updated 2026-10-20 · CC-BY-SA-4.0