🎲 Intro to Probability
Free self-paced course · Certificate on completion

Introduction to Probability

Learn how to think clearly about chance: what probability means, how to count possibilities, how new information changes the odds, and how to describe uncertain quantities like waiting times or exam scores. Each lesson pairs the theory (the main idea in plain words, with everyday examples) with practice: simulations and demos you drive yourself, short code sketches that light up step by step, and quizzes. Then pass the final quiz to earn your certificate.

What you'll learn

  • What probability means, and how to count outcomes and apply the basic rules.
  • How new information changes chances: conditional probability, independence and Bayes' theorem.
  • How random variables, expected values and common distributions describe real-world uncertainty.

Theory

The main ideas of probability in plain words, with everyday cases: coins, dice, cards, buses, medical tests and spam filters.

Practice

Interactive demos: flip 1,000 coins, light up a Venn diagram (events drawn as circles), grow a counting tree, test 1,000 people for a disease, and explore distributions. A quiz in every lesson.

Certificate

Score 80% or more on the final quiz to get a certificate with your name, ready to print, save as PDF or download as an image.

  • 9 lessons in 3 parts
  • 27 lesson quiz questions
  • 10-question final quiz
  • Only school arithmetic needed: no calculus, no coding
  • Self-paced · works offline

How the course works

  1. Part A: Chance and countingwhat probability means, the language of events, counting possibilities, and the basic rules.
  2. Part B: Updating with informationhow knowing something changes the chances: conditional probability, independence and Bayes' theorem.
  3. Part C: Random variablesturning outcomes into numbers: averages, spread, common distributions, and how two quantities move together.
  4. In each lessonread the idea, try the interactive demo, follow the code beside it, then take the lesson quiz.
  5. Take the final quiz10 questions on the main concepts. Score 8 of 10 or more (80%) to earn your certificate.
Tip: every formula appears with a worked example in real numbers. The code panels are short, readable Python sketches of the same calculation; you don't need to run them or know Python to follow along. Use the Animation speed slider at the top to slow down any demo, and retake any quiz as often as you like.

Course map

Part A · Chance and counting

Part B · Updating with information

Part C · Random variables

Part A · Chance and counting

What probability means, the language of events, counting possibilities, and the basic rules.

1. Why probability? (measuring uncertainty)

Probability is a number between 0 and 1 that says how likely something is: 0 means it can't happen, 1 means it's certain, and ½ means it's as likely as not. We often write it as a percentage, from 0% to 100%.

Life is full of uncertainty: will it rain, will the bus be late, which side will a tossed coin land on? We can't know the answer in advance, but we can measure how likely each answer is. A forecast of "70% chance of rain" doesn't promise rain; it says that rain is more likely than not, so an umbrella is a good idea.

The words we use

Our first examples use a coin and a die. A coin has two sides, called heads and tails; a fair coin lands on each side with the same chance. A die (plural: dice) is a small cube whose six faces show the numbers 1 to 6. When you roll it, one face ends up on top, and on a fair die each of the six numbers has the same chance.

HT coin: 2 sides, heads (H) and tails (T) die: 6 faces, showing 1 to 6
TermMeaningExample (rolling a die)
Random experimentanything with an uncertain result that we can repeatrolling a die
Outcomeone possible resultrolling a 4
Eventa group of outcomes we care about"an even number": 2, 4 or 6

See it settle: the law of large numbers

Flip a fair coin a few times and the share of heads jumps around. Flip it many times and the share settles close to 50%. Try it with a coin, or switch to the die and watch the share of sixes settle near 1/6:

Coin flips
Law of large numbers: with only a few trials, the share of an outcome can be far from its probability. With many trials, it gets close and stays close. That's why "3 heads in a row" says almost nothing about a coin, while 1,000 flips say a lot.

Three ways to find a probability

From here on we write the probability of an event in short as P(event). For example, P(heads) means "the probability of heads", and P(late) means "the probability that the bus is late". The sign ≈ means "about".

ApproachHow it worksExample
Classicalcount the outcomes, when they are all equally likelya fair coin: 1 of 2 outcomes is heads, so P(heads) = ½
Frequencyuse the share of times it happened in many repeated trialsthe bus was late on 6 of the last 50 days, so P(late) ≈ 6/50 = 12%
Subjectivea reasoned degree of belief, when we can't count or repeat"I'm 80% sure this project will finish on time"

A weather forecast mixes these ideas: forecasters look at how often it rained on past days with similar conditions (frequency), using computer models and expert judgement.

Where it shows up

  • Weather forecasts, insurance prices and medical risk estimates.
  • Games of chance, sports predictions and quality control in factories.
  • Data science and AI, where models output probabilities, like "90% likely to be spam" (unwanted junk email).

2. Sets and sample spaces (the language of events)

The sample space, written Ω (the Greek letter omega), is the set of all possible outcomes of an experiment. A set is simply a collection of things, written between curly brackets: {2, 4, 6} is the set of the numbers 2, 4 and 6. An event is a part of the sample space, a subset (a set inside a bigger set). For a die roll, Ω = {1, 2, 3, 4, 5, 6} and the event "even" is the subset {2, 4, 6}. Thinking of events as sets lets us combine them with three simple operations: "or", "and" and "not".

Think of the sample space as a room with everyone in it. An event is a circle drawn on the floor: some people stand inside, the rest outside. Combining events is just asking who stands inside one circle, inside both, or outside.

Union, intersection and complement

We name events with capital letters, like A and B. In the table, A is "the roll is even" = {2, 4, 6} and B is "the roll is greater than 3" = {4, 5, 6}.

OperationSymbolIn wordsDie example (A = even, B = greater than 3)
UnionA ∪ BA or B (or both){2, 4, 5, 6}
IntersectionA ∩ BA and B{4, 6}
ComplementAᶜnot A{1, 3, 5}

A Venn diagram draws Ω as a box and each event as a circle, so these operations become regions you can see. The demo has three examples: a die roll; a class of 30 students, where some take math and some take physics; and a die roll split into even and odd numbers. Pick an example and an operation:

Mutually exclusive events

Two events are mutually exclusive (or disjoint) when they can't happen together: their intersection is empty, A ∩ B = ∅. "Even" and "odd" on one die roll are mutually exclusive; "even" and "greater than 3" are not, because a 4 or a 6 is both. In the diagram, mutually exclusive events are circles that don't overlap (try Even vs odd above).

Every probability question starts the same way: what is Ω, and which part of it is my event? Writing the sets down first prevents most mistakes.

Where it shows up

  • Surveys: customers who bought product A, product B, both or neither.
  • Search and databases: "cats AND dogs" (intersection), "cats OR dogs" (union), "NOT cats" (complement).
  • Every probability rule in the next lessons is written with these three operations.

3. Counting (how many possibilities?)

Many probabilities are "favourable outcomes ÷ all outcomes", where the favourable outcomes are the ones that belong to our event, so we need to count outcomes, often too many to list. Three tools do it: the multiplication rule, permutations (arrangements where order matters) and combinations (selections where it doesn't).

Think of ordering a meal: 3 starters, 4 mains and 2 desserts. You don't need to write out every menu; each starter can go with each main and each dessert, so there are 3 × 4 × 2 = 24 menus.

The multiplication rule

If a choice happens in steps, with a options in the first step, b in the second and c in the third, the total is a × b × c. A 4-digit PIN has 10 choices for each digit, so there are 10 × 10 × 10 × 10 = 10,000 PINs.

Permutations and combinations

In the meal example, each step chose from a different list: a starter, then a main, then a dessert. Often we instead choose several items from the same group, for example 3 people out of a group of 5. Then something changes: a person who has already been picked can't be picked again, so each pick has one choice fewer than the pick before it.

When we pick from one group like this, there are two different questions we can ask, and they have different answers:

  • Does the order of the picks matter? For example, the first person picked gets gold, the second silver, the third bronze. Then each ordered pick is called a permutation.
  • Does only the group matter? For example, the 3 people form a team, and nobody has a special place. Then each group is called a combination.

Let's count both, using the same group of people.

Example: 5 people, called A, B, C, D and E. In how many ways can we pick 3 of them, one after another?

  1. First pick: any of the 5 people, so 5 choices.
  2. Second pick: the first person is already taken, so 4 are left.
  3. Third pick: two people are taken, so 3 are left.

Each first choice can go with each second choice and each third choice, so by the multiplication rule there are 5 × 4 × 3 = 60 ordered picks. You can check it: the picks that start with A are AB_, AC_, AD_ and AE_, each with 3 people left for the last place, so 4 × 3 = 12 of them. Each of the 5 people can be first, and 5 × 12 = 60.

These 60 ordered picks are the permutations of 3 people from 5. The order counts, so ABC (A first, B second, C third) and CBA (C first, B second, A third) are two different permutations. This is the right count when the places mean something, like gold, silver and bronze medals.

Now suppose we only want a team of 3, where nobody has a special place. The six orders ABC, ACB, BAC, BCA, CAB and CBA all describe the same team: A, B and C. So the 60 ordered picks count each team several times. How many times? That's the number of ways to put 3 people in order, and it is the multiplication rule again: 3 choices for who goes first, then 2, then 1, so 3 × 2 × 1 = 6.

This "count down to 1" product has a name: the factorial, written n! and read "n factorial". n! = n × (n − 1) × … × 1 is the number of ways to put n things in order, so 3! = 6.

Every team appears 3! = 6 times among the 60 ordered picks, so the number of different teams is 60 ÷ 6 = 10. These 10 teams are the combinations of 3 people from 5: the order doesn't count.

PermutationsCombinations
Order matters?yes: ABC and CBA are differentno: ABC and CBA are the same group
Question"In how many ways can we arrange or rank?""In how many ways can we choose a group?"
Choose 3 of 55 × 4 × 3 = 6060 ÷ 3! = 10
Examplesgold, silver and bronze medals; a running ordera team, a handshake, pizza toppings

How the three tools fit together: each one is built from the one before it.

ToolHow to countExample
Multiplication rulethe basic idea: multiply the number of choices at each stepmeals: 3 starters × 4 mains × 2 desserts = 24
Permutations (order matters)the multiplication rule with one choice fewer at each step; for k picks from n: n × (n − 1) × … (k numbers)3 of 5 in order: 5 × 4 × 3 = 60
Combinations (order doesn't matter)permutations ÷ k!, which removes the repeated orders of each groupteams of 3 from 5: 60 ÷ 3! = 60 ÷ 6 = 10
Ask yourself: "If I swap two of my choices, is it a different result?" If yes, order matters (permutation). If no, it's a combination: count the arrangements, then divide by the number of ways to order the chosen items.

The demo below has two modes. Outfits builds outfits from 3 shirts, 2 pairs of trousers and 2 pairs of shoes, using the multiplication rule (3 × 2 × 2 = 12). Team of 3 repeats the example above: it lists the 60 ordered picks (permutations), groups the ones with the same 3 people, and ends with the 10 teams (combinations).

Where it shows up

  • Passwords and PINs: each position can hold any allowed character, and characters can repeat (1111 is a valid PIN). The order matters too: 1234 and 4321 are different PINs. So we don't remove any choices; we use the plain multiplication rule. A 4-digit PIN has 10 choices for each of its 4 positions: 10 × 10 × 10 × 10 = 10,000 PINs. A 6-digit PIN has 10 multiplied 6 times = 1,000,000, which is 100 times more: each extra position multiplies the total by the number of choices. A password of 8 small letters has 26 choices per position: 26 multiplied 8 times ≈ 209 billion. Allow capital letters and digits as well (26 + 26 + 10 = 62 choices per position) and 8 characters give about 218 trillion, around 1,000 times more. You can check the method with a 2-digit PIN: 10 × 10 = 100, and the list is 00, 01, 02, … up to 99.
  • Handshakes: 10 people meet, and each person shakes hands once with every other person. How many handshakes? Count ordered pairs first: 10 choices for the first person, then 9 for the second, so 10 × 9 = 90. But A shaking hands with B is the same handshake as B shaking hands with A, so every handshake was counted 2! = 2 times. That leaves 90 ÷ 2 = 45 handshakes, a combination of 2 people from 10. You can check the method with 4 people, A, B, C and D: 4 × 3 ÷ 2 = 6, and the list is AB, AC, AD, BC, BD and CD.

4. Basic probability rules (combining chances)

A few simple rules let us work out the probability of "A or B" and "not A" from probabilities we already know. When all outcomes are equally likely, a probability is just counting: favourable outcomes ÷ all outcomes.

Think of a prize draw: 100 numbered tickets go into a box and one is drawn at random. If you hold 5 of the tickets, your chance of winning is 5/100 = 5%. The rules below are common sense written down, so you can use them even when the numbers get bigger.

The three basic rules (axioms) in plain words

  1. Between 0 and 1: every probability is at least 0 and at most 1.
  2. Something happens: the whole sample space has probability 1, P(Ω) = 1.
  3. Separate events add up: if A and B are mutually exclusive (can't happen together), P(A ∪ B) = P(A) + P(B).

Everything else follows from these three axioms.

The examples below use a standard deck of playing cards. In case you haven't used one: a deck has 52 cards, split into 4 suits (groups, each with its own symbol): ♥ hearts and ♦ diamonds are red, ♠ spades and ♣ clubs are black. Each suit has the same 13 ranks: A (ace), 2, 3, 4, 5, 6, 7, 8, 9, 10, J (jack), Q (queen) and K (king). J, Q and K show a picture of a person, so they are called face cards: 3 in each suit, 12 in the whole deck. Every card appears exactly once, so 4 suits × 13 ranks = 52 cards.

A♥♥7♦♦4♠♠9♣♣ 4 suits: ♥ ♦ red, ♠ ♣ black J♥JQ♥QK♥K face cards: J, Q, K

In practice, the rules you'll use most are:

RuleFormulaExample with a deck of 52 cards
Equally likely outcomesP(A) = favourable ÷ totalP(heart) = 13/52 = 1/4
Addition ruleP(A ∪ B) = P(A) + P(B) − P(A ∩ B)P(heart or face card) = 13/52 + 12/52 − 3/52 = 22/52
Complement ruleP(Aᶜ) = 1 − P(A)P(not a heart) = 1 − 13/52 = 39/52

Adding probabilities: when events can't happen together

The question: why, for mutually exclusive A and B, is P(A or B) = P(A) + P(B)? Think about it for a moment, then step through the demo below.

Recall from lesson 2: two events are mutually exclusive when they can't happen at the same time, so they share no outcomes (A ∩ B = ∅). A spinner shows this clearly. It is a circle split into 4 equal sections, numbered 1 to 4, with a needle in the middle: you spin the needle, and the section where it stops is the result. Let A = "the needle lands on 1" and B = "the needle lands on 3". In the demo, section 1 is blue and section 3 is green. Press Next, Back or Reset to move through the steps.

A spinner with 4 equal sections

The same idea works on the die from lesson 2. Take one roll with A = "even" = {2, 4, 6} and B = "odd" = {1, 3, 5}. In the picture, the blue circle is A and the green circle is B, and they don't touch.

Ω A = even B = odd 246 135
Mutually exclusive: no outcome is in both circles, so nothing is counted twice.

"A or B" means the roll lands in either circle. Because the circles don't overlap, every outcome in "A or B" is in exactly one of them, so we can count each circle on its own and add: 3 outcomes + 3 outcomes = 6 outcomes. As probabilities: P(A or B) = P(A) + P(B) = 3/6 + 3/6 = 6/6 = 1. That's correct: every roll is either even or odd. This is the third axiom above ("separate events add up"), seen on a picture.

The addition rule: when events overlap

The question: why is P(A or B) = P(A ∪ B) = P(A) + P(B) − P(A ∩ B)? In other words, why subtract the overlap? Think about it for a moment, then read on.

Now keep A = "even" = {2, 4, 6} but change B to "greater than 3" = {4, 5, 6}, the events from lesson 2. These two can happen together: a roll of 4 or 6 is both. In the picture, the blue circle is A, the green circle is B, and the purple region is their overlap A ∩ B = {4, 6}.

Ω A = even B = greater than 3 2465 13 ×2×2
Overlapping: 4 and 6 sit in both circles, so simply adding the two circles counts them twice (orange ×2).
  1. Just add, as before: P(A) + P(B) = 3/6 + 3/6 = 6/6 = 1. But that's too big: a probability of 1 would mean every roll is even or greater than 3, yet a roll of 1 or 3 is neither.
  2. Find the mistake: counting A gives 2, 4, 6 and counting B gives 4, 5, 6, so 4 and 6 were counted twice, once in each circle (the orange ×2 marks).
  3. Fix it: subtract the double-counted overlap once: P(A) + P(B) − P(A ∩ B) = 3/6 + 3/6 − 2/6 = 4/6.
  4. Check by counting: A ∪ B = {2, 4, 5, 6}, which is 4 of the 6 outcomes: 4/6 ✓.

So the addition rule is P(A ∪ B) = P(A) + P(B) − P(A ∩ B), and the mutually exclusive case is just the special case where the overlap is empty: P(A ∩ B) = 0, so there is nothing to subtract. The two die examples give the same total, 3/6 + 3/6 = 1, but it is right for "even or odd" (no overlap) and wrong for "even or greater than 3" (overlap). Always ask first: can both happen at once?

The same thing happens with cards. The cards that are both hearts and face cards (J♥, Q♥, K♥) are counted once in "hearts" and once in "face cards", so the addition rule subtracts them once: 13/52 + 12/52 − 3/52 = 22/52. See it on the deck:

A standard deck · 52 equally likely cards

The complement rule: the chance that something doesn't happen

The question: how do we find the probability that A does not happen? Think about it for a moment, then read on.

Roll a die once, and let A = "a six" = {6}, so P(A) = 1/6. "Not A" is written Aᶜ, the complement from lesson 2: every outcome that is not in A, here {1, 2, 3, 4, 5}. In the bar below, each cell is one face of the die (count the dots): the orange cell is A and the blue cells are Aᶜ.

Aᶜ = not a six: 5 of 6 cells = 5/6 A: 1/6 the whole bar = all 6 outcomes = P(Ω) = 1

A and Aᶜ can't happen together (a roll is either a six or not), so they are mutually exclusive and we can add them, as in the even and odd example above. Together they fill the whole bar, which is the whole sample space, and P(Ω) = 1 (the second axiom). So P(A) + P(Aᶜ) = 1, which gives the complement rule: P(Aᶜ) = 1 − P(A). Here P(not a six) = 1 − 1/6 = 5/6. Check by counting: 5 of the 6 faces are not a six ✓.

The complement rule is most useful when "not A" is easier to count than A, as the next example shows.

The complement trick: "at least one six"

Here is the complement rule at its most useful: an event that is hard to count directly, but whose opposite is easy. We use the same die, but now roll it several times.

The question: roll a die 4 times. What's the chance that at least one of the 4 rolls shows a six? "At least one" means one six, two sixes, three sixes or four sixes: any number of sixes except zero.

Counting each of those cases is long. The opposite is much simpler: the opposite of "at least one six" is "no six at all". By the complement rule, P(at least one six) = 1 − P(no six). So we only need P(no six), and the counting tools from lesson 3 give it:

  1. All possible results: each roll can show any of 6 faces, so by the multiplication rule 4 rolls can give 6 × 6 × 6 × 6 = 1,296 different sequences (like 3, 6, 1, 1). On a fair die they are all equally likely.
  2. Results with no six: each roll must show one of the other 5 faces (1, 2, 3, 4 or 5), so there are 5 × 5 × 5 × 5 = 625 sequences with no six.
  3. P(no six) = 625 ÷ 1,296 ≈ 0.482. This is the same as (5/6) × (5/6) × (5/6) × (5/6): for each roll, 5 of the 6 faces avoid a six. Multiplying 5/6 by itself 4 times is written (5/6)⁴, and for n rolls it is (5/6)ⁿ.
  4. The answer: P(at least one six) = 1 − 0.482 = 0.518, a little more than half.

Move the slider to change the number of rolls. The green bar is P(at least one six), the orange bar is P(no six), and the two always add up to 1.

P(at least one six)
—
P(no six)
—
When a question says "at least one", try the complement first: 1 − P(none).

Where it shows up

  • Card and board games: the chance of drawing the card you need.
  • Reliability: the chance that at least one of several backup systems works is 1 − P(all of them fail).
  • Risk: the chance of at least one accident, failure or win over many tries.

Part B · Updating with information

How knowing one thing changes the chances of another, and how to reason backwards from evidence.

5. Conditional probability and independence (when you know something)

Conditional probability P(A | B), read "the probability of A given B", is the chance of A once we know that B happened. We zoom into B: only the outcomes in B count now, and we ask what share of them is also in A.

The chance that a random person is wearing a coat might be 30%. But if you know it's snowing outside, the chance is much higher. The extra information doesn't change the people; it changes which group you're looking at.

Why P(A | B) = P(A ∩ B) ÷ P(B)

The question: why is P(A | B) = P(A ∩ B) ÷ P(B), and so P(A ∩ B) = P(A | B) × P(B)? Think about it for a moment, then step through the demo below: five small steps on a single die roll answer it.

Start with the die from lesson 2: one roll, with A = "even" = {2, 4, 6} and B = "greater than 3" = {4, 5, 6}. The demo below works out P(A | B) one step at a time. Press Next to go forward, Back to go back a step, and Reset to start again. In the picture, the blue circle is A, the green circle is B, the purple region is where they overlap (A ∩ B), and outcomes that are ruled out fade.

One die roll · Ω = {1, 2, 3, 4, 5, 6}

So conditioning just rescales the overlap by the size of B: P(A | B) = P(A ∩ B) ÷ P(B) = (2/6) ÷ (3/6) = 2/3. Turned around, it gives the multiplication rule for probabilities: P(A ∩ B) = P(B) × P(A | B) = 3/6 × 2/3 = 2/6.

Zoom in: spam and the word "free"

Now the same zoom-in with real data. Spam means unwanted junk email, such as adverts or scams. Email programs try to spot it, and one clue is the word "free". Here are 100 emails. Orange ones are spam, blue ones are not, and a ★ marks emails that contain the word "free". Zoom in and count:

100 emails · orange = spam · ★ = contains "free"

Notice that P(spam | free) = 77% and P(free | spam) = 80% are different questions with different answers. Swapping A and B in P(A | B) changes the meaning, a common mistake (lesson 6 shows how to go from one to the other).

The formula and the multiplication rule

The numbers below come from the demo: of the 100 emails, 30 are spam, 31 contain "free", and 24 are both spam and contain "free". So P(spam) = 0.30, P(free) = 0.31, P(spam and free) = 0.24, and P(free | spam) = 24/30 = 0.80.

RuleFormulaWith the emails
Conditional probabilityP(A | B) = P(A ∩ B) ÷ P(B)P(spam | free) = 0.24 ÷ 0.31 ≈ 0.77
Multiplication rule for probabilities (also called the product rule)P(A ∩ B) = P(B) × P(A | B)P(spam and free) = 0.30 × 0.80 = 0.24

Careful: this is a different rule from the counting rule in lesson 3, even though both are called a multiplication rule. Lesson 3 multiplies numbers of choices; this one multiplies probabilities. The second row is just the first row turned around (multiply both sides by P(B)), exactly as in the last step of the die demo above.

Two draws from a box: the multiplication rule as a tree

The question: why is P(A and B) = P(A ∩ B) = P(A) × P(B | A), when A happens first and B second? Think about it for a moment, then step through the demo below.

A box holds 3 red and 5 blue balls, 8 in total. We draw two balls, one after the other, without replacement: the first ball stays out, so the box changes before the second draw. Let A = "the first ball is red" and B = "the second ball is blue". What is P(A and B)?

The demo shows the box before each draw (red and blue dots are the balls) and a tree diagram: each branch is one possible draw, labelled with its chance, and each path from left to right is one possible result of both draws. The orange path is the one we follow. Press Next, Back or Reset to move through the steps.

A box of 3 red and 5 blue balls · two draws

So for events that happen one after the other, multiply along the path: the chance of the first step, times the chance of the second step given the first. This is the multiplication rule from the table above, P(A ∩ B) = P(B) × P(A | B), just written in the order things happen: when A comes first, condition on A, so P(A ∩ B) = P(A) × P(B | A). Both give the same P(A ∩ B).

Notice the last step: when the first ball is put back (with replacement), the box is the same for the second draw, so the first draw no longer changes the second one: P(B | A) = P(B) = 5/8. Events like that have a name, which is the next idea.

Independent events

The question: why, for independent A and B, is P(A and B) = P(A) × P(B)? Think about it for a moment, then read on.

Two events are independent when knowing one doesn't change the chance of the other: P(A | B) = P(A). In words: the chance of A is the same whether or not we know that B happened, so B gives no information about A.

Example: toss a coin and roll a die at the same time. Let A = "the coin shows heads" and B = "the die shows an even number" (2, 4 or 6). Step through the demo: the grid has one cell for every possible result, with the coin as the row (H = heads, T = tails) and the die as the column. Press Next, Back or Reset to move through the steps.

A coin toss and a die roll

Why independence makes "and" so simple. The multiplication rule from the tree says P(A ∩ B) = P(A) × P(B | A). For independent events, P(B | A) is just P(B), as step 4 showed, so we can swap it in: P(A ∩ B) = P(A) × P(B). For the coin and die: 1/2 × 1/2 = 1/4, which is 3 of the 12 cells. Compare the emails above, where knowing "free" raised the chance of spam from 0.30 to 0.77, and the box of balls, where the first draw changed the second unless the ball was put back: those events are not independent, so you must use P(B | A).

IndependentNot independent (dependent)
two separate coin flips"spam" and "contains free"
rolling a die and drawing a card"cloudy" and "rain"
drawing a card, putting it back, then drawing againdrawing two cards without putting the first back

For example, the chance of two heads in two flips is ½ × ½ = ¼, because the second flip doesn't care about the first.

The gambler's fallacy

After five heads in a row, many people feel tails is "due". It isn't: a coin has no memory, so each flip is still 50/50. This mistake is called the gambler's fallacy. Check it with a big simulation:

and look at the flip right after every 5 heads in a row
next flip was heads
—
next flip was tails
—

Where it shows up

  • Spam filters and recommendations: the chance of something (spam, a product you'd like) given the words or clicks we've seen.
  • Medicine: the chance of a disease given a symptom or a test result (next lesson).
  • Insurance: the chance of a claim given age, location or history.

6. Total probability and Bayes' theorem (reasoning backwards from evidence)

Often we know how likely the evidence is if something is true, but we want the reverse: how likely it is to be true, given the evidence. Bayes' theorem turns P(evidence | cause) into P(cause | evidence). Its partner, the law of total probability, adds up all the ways the evidence can happen.

Think of a smoke alarm. It almost always beeps when there's a fire, but it also beeps for burnt toast. When it beeps, how likely is a real fire? It depends on how often each cause happens, and burnt toast is far more common than fires.

The law of total probability

The question: why is P(B) = Σᵢ P(B ∩ Aᵢ) = Σᵢ P(B | Aᵢ) × P(Aᵢ)? Here B is an event, A₁, A₂, … are slices that split the sample space (explained just below), and Σᵢ means "add up over every slice i". Think about it for a moment, then step through the demo below: five small steps on a single die roll answer it.

The idea: slice the sample space into pieces, find how much of the event sits in each piece, then add the pieces up. It helps when an event is hard to count directly but easy to count inside each piece. We'll see it first on the die from lesson 2, then use it on a real example.

The slices must form a partition. Like the slices of a cake, they don't overlap (every outcome is in exactly one slice), and together they cover everything (nothing is left out). Here the event is B = "the roll is even" = {2, 4, 6}, and the slices are A₁ = {1}, A₂ = {2, 3, 4} and A₃ = {5, 6}; the small numbers just number the slices. In the demo, the blue outline is B, and the orange, green and pink strips are the three slices. Press Next, Back or Reset to move through the steps.

One die roll · B = even · slices A₁, A₂, A₃

Now a real example: the smoke alarm from the start of this lesson. Here the event is a beep, and the slices are the three things that can happen on an evening: a fire, burnt toast, or a quiet evening. Picture 1,000 evenings in one kitchen:

  • A real fire happens on 2 evenings, and the alarm beeps every time: 2 beeps.
  • Burnt toast happens on 100 evenings, and its smoke sets the alarm off 30% of the time: 30% of 100 = 30 beeps.
  • On the other 898 evenings nothing happens and the alarm stays quiet. (To keep it simple, a fire and burnt toast never happen on the same evening.)

How often does the alarm beep? A beep comes either from a fire or from toast, never from both, so we count each way on its own and add them: 2 + 30 = 32 beeps in 1,000 evenings, so P(beep) = 32 ÷ 1,000 = 0.032.

The same steps with probabilities. "The alarm beeps every time there's a fire" is a conditional probability: P(beep | fire) = 1. To get the chance of a fire and a beep on an evening, use the multiplication rule for probabilities from lesson 5 (also called the product rule), P(A ∩ B) = P(B) × P(A | B):

  • P(beep ∩ fire) = P(fire) × P(beep | fire) = 0.002 × 1 = 0.002
  • P(beep ∩ toast) = P(toast) × P(beep | toast) = 0.10 × 0.30 = 0.030

Adding the two ways gives P(beep) = 0.002 + 0.030 = 0.032, the same as counting. The table below shows the same steps.

In general: if something can happen in several separate ways, its total probability is the sum over those ways: P(B) = P(B | A₁) × P(A₁) + P(B | A₂) × P(A₂) + …. Here B is the event we care about (a beep), and A₁, A₂, … are the separate situations it can come from (a fire, burnt toast, a quiet evening). The small numbers just number them. They must be mutually exclusive and cover every case; a situation that never causes B, like a quiet evening, simply adds 0.

Smoke alarmHow often: P(situation)Beep chance: P(beep | situation)Beeps: P(situation) × P(beep | situation)
Fire2 of 1,000 = 0.00210.002 × 1 = 0.002
Burnt toast100 of 1,000 = 0.100.300.10 × 0.30 = 0.030
Quiet evening898 of 1,000 = 0.89800.898 × 0 = 0
Total1,000 of 1,000 = 1P(beep) = 0.032 (32 beeps in 1,000 evenings)

Bayes' theorem

Bayes' theorem links two events:

  • The cause (A) is the possible explanation we want to find out about but can't see directly, such as "there is a fire".
  • The evidence (B) is what we actually observe, such as "the alarm beeps".

We usually know how likely the evidence is for each possible cause, P(evidence | cause). We want the reverse, P(cause | evidence).

ExampleCause A (hidden)Evidence B (observed)We know P(B | A)We want P(A | B)
Smoke alarmthere is a firethe alarm beepsP(beep | fire) = 1 in our exampleP(fire | beep)
Medical test (demo below)the person has the diseasethe test is positiveP(positive | disease): how often the test finds itP(disease | positive)

The formula is P(A | B) = P(B | A) × P(A) ÷ P(B). In words: how likely the evidence is if the cause is true, times how common the cause was before we saw any evidence, divided by how common the evidence is overall.

For the smoke alarm: the alarm beeps; how likely is a real fire? Here A = "there is a fire" and B = "the alarm beeps", and the three numbers come from the total probability example above:

  • P(B | A) = P(beep | fire) = 1: if there's a fire, the alarm always beeps.
  • P(A) = P(fire) = 0.002: how common fires are before we hear anything (the base rate).
  • P(B) = P(beep) = 0.032: how often the alarm beeps overall, from the law of total probability.

So P(fire | beep) = 1 × 0.002 ÷ 0.032 ≈ 0.06 = 6%. Check it with the counts: of the 32 beeps, only 2 were a fire, and 2 ÷ 32 ≈ 6%. The formula and the counting give the same answer.

Why so low? The alarm is reliable, but fires are rare and burnt toast is common, so most beeps come from toast. That's the base rate at work. It doesn't mean you can ignore the alarm: a 6% chance of a fire is serious, so you always check.

The easiest way to use Bayes is with counts of people instead of percentages. Take a medical test for a disease. A test result is positive when the test says "you have it", and negative when it says "you don't". Tests make mistakes both ways. The demo has three sliders:

  • how common: the share of people who really have the disease (the base rate),
  • test finds: the share of sick people the test correctly flags as positive,
  • false alarms: the share of healthy people the test wrongly flags as positive.

With the starting values: 1% of 1,000 people = 10 are sick, and the test finds 90% of them, so 9 true positives. 9% of the 990 healthy people ≈ 89 false alarms. That's 9 + 89 = 98 positive results, but only 9 of them are sick: P(sick | positive) = 9 ÷ 98 ≈ 9%. Follow it step by step on 1,000 people:

1,000 people · ● sick · ■ tested positive
Base rates matter: when a condition is rare, most positive results are false alarms, even with a good test, simply because there are so many more healthy people to make mistakes on. Raise "how common" to 10% and the same positive test means about a 53% chance: 100 people are sick and 90 of them test positive; 9% of the 900 healthy ≈ 81 false alarms; 90 ÷ (90 + 81) = 90 ÷ 171 ≈ 53%. Always ask how common the thing was to begin with: the base rate.

Where it shows up

  • Medical screening: why a positive result is usually followed by a second, more accurate test.
  • Spam filters: the chance an email is spam, given the words it contains (a classic use of Bayes).
  • Quality control and fraud detection: which machine, account or process is the likely cause of a problem.

Part C · Random variables

Turning outcomes into numbers: averages, spread, ready-made distributions, and two quantities together.

7. Random variables (outcomes as numbers)

A random variable is a number that depends on the outcome of a random experiment, like your winnings in a game or the number of customers in an hour. We usually call it X. Its distribution says which values X can take and how likely each one is.

A shop owner can't know how many customers will come in the next hour, but after many hours she knows the pattern: usually 8 to 12, rarely more than 20, and about 10 on average. A random variable and its distribution describe exactly that kind of pattern.

Discrete and continuous

DiscreteContinuous
Valuesseparate values you can list: 0, 1, 2, …any value in a range, like 3.27
Examplesheads in 10 flips, customers per hour, game winningswaiting time, height, temperature
Described byPMF (probability mass function): P(X = x), the chance of each possible value x (capital X is the random variable; small x stands for one particular value it can take, like 3)PDF (probability density function): a curve; probabilities are areas under it
Both haveCDF (cumulative distribution function): P(X ≤ x), the chance of getting x or less. It rises from 0 to 1.

A simple dice game

Roll a die. On a 6 you win 3 points; on a 4 or 5 you win 1 point; on 1, 2 or 3 you lose 1 point. Your winnings X is a discrete random variable with three values: −1, +1 and +3. Is the game worth playing? We'll answer that after working out the expected value below.

First, the PMF of X: each value with its chance. A fair die has 6 equally likely faces, so count the faces that give each value:

Winnings XDie facesP(X = value)
−1 (lose 1 point)1, 2, 33/6 = 0.50
+1 (win 1 point)4, 52/6 ≈ 0.33
+3 (win 3 points)61/6 ≈ 0.17
Totalall 6 faces6/6 = 1

The demo draws this PMF as bars: one bar per value, and each bar's height is that value's chance, so the three heights add up to 1. The CDF button shows instead the chance of getting that value or less: 3/6 for −1, 3/6 + 2/6 = 5/6 for +1 or less, and 6/6 = 1 for +3 or less. Press Play to roll the die many times: the line underneath shows your average winnings per game so far, next to the dashed line at the expected value.

Expected value, variance and standard deviation

MeasureWhat it tells youHow to compute (discrete; Σ means "add up over all values")Dice game
Expected value E[X]the long-run average: the "centre" of the distributionΣ value × probability≈ 0.33 points per game
Variance Var(X)how spread out the values are around E[X]Σ (value − E[X])² × probability≈ 2.22
Standard deviation σthe typical distance from the average, in the same units as X√Var(X)≈ 1.49 points

Working it out for the dice game. First the chance of each value: a 6 is 1 face of 6, so P(win 3) = 1/6; a 4 or 5 is 2 faces, so P(win 1) = 2/6; a 1, 2 or 3 is 3 faces, so P(lose 1) = 3/6.

  • Expected value: multiply each value by its chance and add up: 3 × 1/6 + 1 × 2/6 + (−1) × 3/6 = (3 + 2 − 3) ÷ 6 = 2/6 ≈ 0.33.
  • Variance: for each value, take its distance from 0.33, square it (multiply it by itself), and weight it by its chance: (3 − 0.33)² × 1/6 + (1 − 0.33)² × 2/6 + (−1 − 0.33)² × 3/6 ≈ 1.185 + 0.148 + 0.889 ≈ 2.22. Squaring makes every distance positive, so values below and above the average don't cancel out.
  • Standard deviation: the square root of the variance. √ means "square root": the number that, multiplied by itself, gives 2.22. That's about 1.49, since 1.49 × 1.49 ≈ 2.22. It brings the spread back to the same units as the winnings (points).

So you win about a third of a point per game on average, but any single game varies by about 1.49 points around that. The expected value is not a value you'll see in one game (you never win exactly 0.33 points); it's what the average settles to over many games, just like the law of large numbers in lesson 1. In the same way, "on average 10 customers per hour" is the expected value of the hourly count.

So, is the game worth playing? Yes, if you play many times. The expected value is positive, +0.33 points per game, so over 1,000 games you'd expect to end up about 1,000 × 0.33 ≈ 333 points ahead (press Play 1,000 to see it). But a single game is not a sure win: you lose on 3 of the 6 faces, so half of all games cost you a point, and one game can swing by about 1.49 points. The general rule: a game is worth playing in the long run when its expected value is above 0, and not when it is below 0. Casino games, for example, are designed so the player's expected value is negative.

Continuous variables: probability is area

For a continuous variable, like how long you wait for a call, the chance of any exact value (exactly 3.000… minutes) is 0. Instead we ask about ranges, and the probability is the area under the PDF curve over that range. The total area under the curve is 1.

Waiting time for the next call, averaging 5 minutes. The shaded area is P(wait between 2 and 5 minutes) ≈ 0.30 (the demo computes this area for you).

Where it shows up

  • Games and insurance: expected value tells whether a bet or a policy pays off in the long run.
  • Business planning: expected sales or customers per hour, and their spread, to plan stock and staff.
  • Risk: standard deviation measures how uncertain an outcome is, such as the return on an investment.

8. Common distributions (ready-made models)

Many real situations follow a handful of well-known patterns, called distributions. Each one has a recognisable shape and one or two numbers, its parameters, that set the details. Once you recognise the situation, you get its probabilities, average and spread for free.

Think of clothing sizes: you don't design a new shirt for every person; you pick the right ready-made pattern and adjust the size. Distributions are ready-made patterns for chance: pick the one that matches the situation, then set its parameter.

Explore them

Pick a situation. The matching distribution appears; move the slider to change its parameter and watch the shape, average and spread change.

The seven distributions at a glance

DistributionTypeCounts or measures…Parameter(s)Average
Bernoullidiscreteone yes/no trial (1 = yes, 0 = no)p = chance of yesp
Binomialdiscretenumber of yeses in n independent trialsn, pn × p
Geometricdiscretenumber of trials until the first yesp1 ÷ p
Poissondiscretenumber of events in a fixed time or spaceλ ("lambda") = average countλ
Uniformcontinuousa value where every point in a range is equally likelyrange a to b(a + b) ÷ 2
Exponentialcontinuouswaiting time until the next eventaverage waitthe average wait
Normalcontinuousvalues that cluster around an average in a bell shapeμ ("mu", the mean: another word for the average), σ (standard deviation)μ

How to choose

Ask yourself…Use
Is it one yes/no event?Bernoulli
How many yeses in a fixed number of tries?Binomial
How many tries until the first yes?Geometric
How many events in an hour, a day, a page?Poisson
How long until the next event?Exponential
Any value in a range, all equally likely?Uniform
A measurement that clusters around an average (heights, scores, errors)?Normal
The 68-95-99.7 rule: for a Normal distribution, about 68% of values fall within 1 standard deviation of the mean, 95% within 2, and 99.7% within 3. With exam scores averaging 70 and σ = 10, about 95% of students score between 50 and 90 (70 − 2 × 10 and 70 + 2 × 10). The Normal shows up so often because adding up many small, independent effects tends to produce a bell shape.

Where it shows up

  • Call centres and shops plan staff with Poisson counts and Exponential waiting times.
  • Quality control uses the Binomial (faulty items in a batch) and the Normal (measurement errors).
  • Grading, heights, blood pressure and many measurements are summarised with a mean and a standard deviation.

9. More than one variable (how two quantities move together)

Often we care about two random variables at once: study hours and grades, temperature and ice cream sales. Their joint distribution gives the chance of each pair of values, and covariance and correlation measure whether they tend to rise and fall together.

Think of two dancers. If one steps forward whenever the other does, they move together (positive correlation). If one steps back whenever the other steps forward, they move in opposite directions (negative). If they ignore each other, there's no pattern.

A joint table

For two discrete variables, a table lists the probability of every combination. Here: weather and ice cream sales on a random summer day.

Sales highSales lowTotal (weather)
Sunny0.450.150.60
Rainy0.100.300.40
Total (sales)0.550.451.00

The totals at the edges give each variable on its own: P(sunny) = 0.60, P(high sales) = 0.55. Are they independent? If they were, P(sunny and high) would equal 0.60 × 0.55 = 0.33. It's 0.45, so no: sunny days make high sales more likely, just like dependent events in lesson 5. Two random variables are independent when every cell equals the product of its two totals.

The sum rule and the product rule

A joint table makes two rules easy to see. We write P(X, Y) for "X and Y together", one cell of the table. From these two rules you can derive the other rules for combining probabilities in this course, including conditional probability, the law of total probability and Bayes' theorem. They are also the starting point of many AI methods. Σ with a small Y under it means: add up over every value of Y (here, over "sales high" and "sales low").

RuleFormulaIn wordsWith the table
Sum rule (marginalization)P(X) = ΣY P(X, Y)add a row (or column) of the joint table to get one variable on its ownP(sunny) = P(sunny, high) + P(sunny, low) = 0.45 + 0.15 = 0.60
Product ruleP(X, Y) = P(Y | X) × P(X)a joint chance = conditional chance × chance of the conditionfirst P(high | sunny) = P(sunny, high) ÷ P(sunny) = 0.45 ÷ (0.45 + 0.15) = 0.45 ÷ 0.60 = 0.75; then P(sunny, high) = P(sunny) × P(high | sunny) = 0.60 × 0.75 = 0.45

The same two rules as pictures. The whole box is all days, with area 1, and the area of each region equals its probability. In the first picture the box is split by the dashed line into two columns, one per sales level. Each column's width is its chance, from the bottom row of the table: high sales 0.55, low sales 0.45. Inside each column, the top piece is the sunny days and the bottom piece the rainy days, so the four pieces are the four cells of the table: 0.45 and 0.10 in the high-sales column (0.45 + 0.10 = 0.55), 0.15 and 0.30 in the low-sales column (0.15 + 0.30 = 0.45).

Ω: all days (area 1) Sales high (0.55) Sales low (0.45) sunny: 0.45 sunny: 0.15 rainy: 0.10 rainy: 0.30 P(sunny) = P(sunny, high) + P(sunny, low) = 0.45 + 0.15 = 0.60
Sum rule: P(sunny) = P(sunny and sales high) + P(sunny and sales low) = 0.45 + 0.15 = 0.60. In the picture, the dashed line cuts the sunny region into two pieces; add the two pieces to get all the sunny days.
1. All days: Ω sunny 0.60 rainy 0.40 P(sunny) = 0.45 + 0.15 = 0.60 2. Zoom into sunny days high sales 0.45 of 0.60 = 75% low: 0.15 of 0.60 = 25% P(high | sunny) = 0.45 ÷ 0.60 = 0.75 3. The overlap sunny and high 0.45 0.60 × 0.75 = 0.45
Product rule: P(sunny, high) = P(sunny) × P(high | sunny). 1. The sunny days are 0.45 + 0.15 = 0.60 of all days. 2. Inside the sunny days, the high-sales piece is 0.45 out of 0.60, so P(high | sunny) = P(sunny and high) ÷ P(sunny) = 0.45 ÷ 0.60 = 0.75 (75%). 3. Take 75% of the sunny part: 0.60 × 0.75 = 0.45, the sunny-and-high piece. A share of a share.

Here we read 0.75 from the table, so step 3 only takes us back to 0.45: a check that the rule works. The product rule is most useful the other way round, when you don't have the whole table: if a forecast says P(sunny) = 0.60 and past experience says sales are high on 75% of sunny days, the rule gives P(sunny and high) = 0.60 × 0.75 = 0.45 straight away.

The totals at the edge of the table are called marginal probabilities, because they sit in the margins; that's where "marginalization" comes from. You've met both rules already: the product rule is the multiplication rule for probabilities from lesson 5, and the law of total probability in lesson 6 is the sum rule combined with the product rule.

Bayes' theorem from the two rules: write the product rule both ways, P(X, Y) = P(Y | X) × P(X) = P(X | Y) × P(Y), and divide by P(Y): P(X | Y) = P(Y | X) × P(X) ÷ P(Y), where P(Y) comes from the sum rule. With the table: P(sunny | high) = P(high | sunny) × P(sunny) ÷ P(high) = 0.75 × 0.60 ÷ 0.55 ≈ 0.82. Here P(high) = P(sunny, high) + P(rainy, high) = 0.45 + 0.10 = 0.55 is the sum rule again, this time down the high-sales column. In the first picture: the high-sales column has area 0.55, and its sunny piece is 0.45, so 0.45 ÷ 0.55 ≈ 0.82. On a high-sales day, it was probably sunny.

Covariance and correlation

A joint table works when each variable has only a few values, like sunny or rainy. For numbers that can take many values, like hours of study and exam grades, we draw a scatter plot instead: each dot is one student, placed across by their study hours and up by their grade. The question is the same as before: when one number is high, does the other tend to be high too?

Covariance answers this with a simple recipe. Take 4 students:

StudentHoursGradeHours − average (5)Grade − average (65)Product
A250−3−15(−3) × (−15) = +45
B460−1−5(−1) × (−5) = +5
C670+1+5(+1) × (+5) = +5
D880+3+15(+3) × (+15) = +45
  1. Find each average: hours (2 + 4 + 6 + 8) ÷ 4 = 5; grades (50 + 60 + 70 + 80) ÷ 4 = 65.
  2. Measure each distance from its average: above the average is positive, below is negative.
  3. Multiply the two distances for each student. If both are above their averages, or both below, the product is positive: the two numbers go together. If one is above and the other below, the product is negative: they go in opposite directions.
  4. Average the products: (45 + 5 + 5 + 45) ÷ 4 = 100 ÷ 4 = 25. It's positive, so more hours go with higher grades. (Statistics tools usually divide by one less than the count, 3 here, which gives about 33; the sign and the meaning are the same.)

The sign of the covariance gives the direction, but its size is hard to read, because it depends on the units: with grades out of 10 instead of out of 100, every grade distance is 10 times smaller and so is the covariance, even though the link is exactly the same. Correlation, written r, fixes this. It rescales the covariance so it always lies between −1 and +1: +1 means the dots lie exactly on a rising straight line, −1 exactly on a falling straight line, and 0 means no straight-line pattern at all. Our 4 students lie exactly on a rising line (every 2 extra hours add 10 points), so for them r = +1.

As formulas. E[ ] means "the average of", as in lesson 7, and σX is the standard deviation of X (σY the same for Y):

MeasureFormulaIn wordsThe 4 students
CovarianceCov(X, Y) = E[(X − E[X]) × (Y − E[Y])]the average of (distance of X from its average) × (distance of Y from its average): the recipe above100 ÷ 4 = 25
Correlationr = Cov(X, Y) ÷ (σX × σY)the covariance divided by the two standard deviationsσhours = √((9 + 1 + 1 + 9) ÷ 4) = √5 ≈ 2.24; σgrades = √((225 + 25 + 25 + 225) ÷ 4) = √125 ≈ 11.18; r = 25 ÷ (2.24 × 11.18) = 25 ÷ 25 = +1 (the product is exactly √5 × √125 = √625 = 25; the rounded numbers give 25.04)

The standard deviations use the same distances as the recipe: square each distance (9 = 3 × 3, and so on), average them, and take the square root, just as for the dice game in lesson 7. Dividing by both standard deviations cancels the units, which is why r always stays between −1 and +1, whatever units you measure in. And if you put the same variable in twice, the covariance becomes the variance from lesson 7: Cov(X, X) = Var(X).

MeasureWhat it tells youValues
Covariancethe direction: do the two tend to be above their averages at the same time?positive = together, negative = opposite, near 0 = no straight-line pattern; its size depends on the units
Correlation rdirection and strength, without unitsfrom −1 (perfect opposite) through 0 (none) to +1 (perfect together)

The demo below has two examples:

  • 📚 Study hours vs grade: 40 made-up students. The slider sets how strongly hours and grades are linked in this class, from opposite (−1) to together (+1). It is only there to show what each kind of pattern looks like: in real life, more study usually goes with higher grades, so a negative correlation here would be unusual. The dashed lines mark the two averages. Dots at the top right (both above average) or bottom left (both below) push the correlation up; dots at the top left or bottom right push it down. The bar under the plot shows r: it grows to the right in green when r is positive, and to the left in orange when it is negative.
  • 🍦 Ice cream vs drownings: 40 summer days across a whole country. Each dot is one day: how much ice cream was sold, and how many people drowned. Look at the correlation first, then press Show the hidden cause to colour each day by its temperature.
correlation r
—
Correlation is not causation. Ice cream sales and drownings rise together, but ice cream doesn't cause drowning: hot weather drives both (more ice cream, more swimming). A hidden third factor like this is called a confounder. Correlation tells you two things move together, not why.

One more link: if two random variables are independent, their covariance and correlation are 0, because neither tells you anything about the other.

Where it shows up

  • Finance: investments that don't rise and fall together (low or negative correlation), like shares in very different companies, are combined so a loss in one is often balanced by another, which reduces risk.
  • Health and social research: spotting links (like exercise and blood pressure), then testing whether one actually causes the other.
  • Data science: checking which measurements move together before building a model.

Glossary & formulas

The key terms and formulas from the course on one page. Filter by topic to revise before the final quiz.

Glossary

Formula sheet

FormulaIn wordsExample
P(A) = favourable ÷ totalequally likely outcomesP(heart) = 13/52
a × b × cmultiplication rule for counting choices in steps3 × 2 × 2 = 12 outfits
n! = n × (n − 1) × … × 1ways to put n things in order3! = 6
Permutations: n × (n − 1) × … (k terms)choose k of n when order matterschoose 3 of 5 in order: 60
Combinations: permutations ÷ k!choose k of n when order doesn't matterteams of 3 from 5: 60 ÷ 6 = 10
P(A ∪ B) = P(A) + P(B) − P(A ∩ B)addition rule ("or")heart or face card: 22/52
P(Aᶜ) = 1 − P(A)complement rule ("not")at least one six in 4 rolls: 1 − (5/6)⁴ ≈ 0.52
P(A | B) = P(A ∩ B) ÷ P(B)conditional probability: zoom into BP(spam | free) = 0.24 ÷ 0.31 ≈ 0.77
P(A ∩ B) = P(A) × P(B | A)"and", one step after another: multiply along a tree pathred then blue: 3/8 × 5/7 = 15/56
P(A ∩ B) = P(A) × P(B)"and" for independent eventsheads and even: ½ × ½ = ¼
P(X) = ΣY P(X, Y)sum rule (marginalization)P(sunny) = 0.45 + 0.15 = 0.60
P(X, Y) = P(Y | X) × P(X)product ruleP(sunny, high) = 0.75 × 0.60 = 0.45
P(B) = Σ P(B | Aᵢ) × P(Aᵢ)law of total probabilityP(beep) = 0.002 × 1 + 0.10 × 0.30 = 0.032
P(A | B) = P(B | A) × P(A) ÷ P(B)Bayes' theoremP(sick | positive) ≈ 9 ÷ 98 ≈ 9%
E[X] = Σ x × P(X = x)expected value: the long-run averagedice game: 0.33 points
Var(X) = Σ (x − E[X])² × P(X = x), σ = √Var(X)spread around the averagedice game: σ ≈ 1.49 points
Binomial mean n × p · Poisson mean λ · Geometric mean 1 ÷ paverages of common distributions10 tosses: 5 heads on average
68 · 95 · 99.7share of a Normal within 1, 2, 3 standard deviations of the meanscores 70 ± 10: 68% between 60 and 80
Cov(X, Y) = E[(X − E[X]) × (Y − E[Y])]covariance: do two variables move together? (sign = direction)4 students: 100 ÷ 4 = 25
r = Cov(X, Y) ÷ (σX × σY)correlation: covariance without units4 students: 25 ÷ (2.24 × 11.18) = +1
−1 ≤ r ≤ +1correlation: direction and strength of a straight-line relationshipstudy hours and grades: r ≈ 0.8

Final quiz & certificate

This is the last step of the course: one list of 10 questions on the main concepts of every lesson. After each answer you'll see the correct option and why it's right. Score 80% or more (8 of 10) to earn a certificate with your name.