Random variables and probability tables · Statistics &… | StemPy Lab
Course 4.1·Lesson 1 of 3
Random variables and probability tables
A random variable is a number that comes from chance, such as the number of brothers and sisters of a student picked at random. Its probability distribution lists every value with its probability. We build one from a made-up class survey, draw it as a bar chart and read probabilities from it.
about 25 min1 simulation1 practice question
Lesson 1 of 3Show all lessonsHide
Try the code and the simulations beside the lesson.
What you will be able to do
say what a random variable is, and tell a discrete one from a continuous one;
build a probability table from counts, and check that it is a real distribution;
read probabilities such as P(X≥2) from a table or a bar chart.
A question with a number for an answer
A made-up class survey asks 40 students one question: how many brothers and sisters do you have? Now pick one student at random. Before you ask, you cannot know the answer. It could be 0, 1, 2 or 3.
A number like this, which comes from a chance process, is a random variable. We give it a capital letter, such as X. A small letter, such as x, stands for one of its values. So "X=2" means "the student picked has two brothers or sisters".
A random variable that counts things, like this one, is discrete: its values are separate numbers. A random variable that measures, such as a height or a waiting time, is continuous: it can take any value in a range. This course is about discrete ones. The last course of the chapter meets a continuous one, the normal distribution.
A probability table
Here are the survey counts. A student picked at random has the answer 1 with probability 4018=0.45, because 18 of the 40 students said 1.
x
0
1
2
3
students
8
18
10
4
P(X=x)
0.2
0.45
0.25
0.1
The last row is the probability distribution of X. It gives every value with its probability. Every distribution obeys two rules.
Each probability is between 0 and 1.
The probabilities add up to 1, because X always takes exactly one of its values.
Here 0.2+0.45+0.25+0.1=1, so the table passes.
A bar chart of the number of brothers and sisters of a student picked at random from a made-up class survey of 40 students. The bars for 0, 1, 2 and 3 have heights 0.2, 0.45, 0.25 and 0.1, written above each bar, and the bar for 1 is the tallest.
A bar chart shows the same table as a picture. The tallest bar is the most likely value. The shape tells you at a glance that most students have one brother or sister, and few have three.
You should find that the bars always share out a total of 1, whatever the counts. Double every count and nothing changes, because each probability is a share of the class.
Reading a table
Many questions ask for more than one value at once. Add the probabilities of the values you want.
P(X≥2)=P(X=2)+P(X=3)=0.25+0.1=0.35.
P(X≤1)=0.2+0.45=0.65. This is also 1−0.35, the complement.
A distribution can also come from equally likely outcomes. Think of a family with two children, and suppose each child is equally likely to be a girl or a boy. The four orders GG, GB, BG and BB are equally likely. So the number of girls has P(0)=41, P(1)=42 and P(2)=41.
Try it in Python
The program counts the answers of the made-up survey, turns each count into a probability and draws the bar chart.
Your turn
The usual mistakes
A table that does not add up to 1. Check the total every time. A missing value or a typing slip shows up at once.
Dividing by the wrong total. A probability from a survey is a count divided by the number of people asked.
Mixing up X and x.X is the random variable. x is one of its values.
Forgetting the end values. "At least 2" includes 2. "More than 2" does not.
Remember these
A random variable is a number that comes from chance.
Its distribution gives each value x with P(X=x). Each probability is from 0 to 1, and they add up to 1.
Add the probabilities of the values you want. Use the complement when it is shorter.
Check yourself
Try each one on your own first. If you are stuck, open a hint. Then check with Show the answer.
Which of these are discrete and which are continuous: the number of goals in a match, and the time a runner takes for 100 m?
A table has P(X=0)=0.1, P(X=1)=0.3 and P(X=3)=0.2. The only other value is 2. Find P(X=2).
A student writes a table with probabilities 0.5, 0.4 and 0.3. Can it be a probability distribution?
A spinner has four equal parts labelled 1, 1, 2 and 5. Let X be the number it lands on. Write the distribution of X.
Use the survey table. What is the probability that a student picked at random has fewer than two brothers and sisters?
References
OpenStax, Introductory Statistics, Chapter 4, section on probability distribution functions for a discrete random variable.
Enroll free in Random Variables and Expected Value
Every lesson is open to read. Enrolling also lets you:
Mark lessons done and carry on where you stopped.
Take the tests of this lesson and its course.
Count the course towards the certificate for its chapter.