Home / Topics / Probability
Course · Probability foundations

Probability, from coin flips to Bayes.

Seven hands-on lessons. Spin spinners, roll dice, flip coins — watch randomness reveal its hidden patterns. By the end, probability stops feeling like luck and starts feeling like math.

7 lessons ~40 min 6 live demos 6 quizzes Beginner → intermediate
01

What is probability?

Probability is a number between 0 and 1 that measures how likely an event is to occur. A probability of 0 means impossible. A probability of 1 means certain. Everything real lives somewhere between.

We write the probability of event A as P(A). For a fair coin, P(Heads) = 0.5. For rolling a 6 on a fair die, P(6) = 1/6 ≈ 0.167.

i
The core intuition: probability measures long-run frequency. If you flip a coin a million times, about half will be heads — not because each flip "knows" what the others did, but because the math says so.

There are three main interpretations of probability: classical (count equally likely outcomes), frequentist (long-run proportion), and Bayesian (degree of belief). All three are useful. We'll touch all of them.

P(A) = number of favourable outcomes / total number of equally likely outcomes

Demo 1 · Flip a coin

Live

Flip once or many times and watch the running proportion creep toward 0.5.

🪙
last flip
0
Heads
0
Tails
0
Total
H proportion: ideal: 0.5
Press "Flip once" to start.
Quick check

Probability basics

A standard die has 6 faces. What is P(rolling an even number)?
A 1/6
B 1/2
C 2/3
D 1
02

Sample spaces & events

The sample space Ω (omega) is the set of all possible outcomes of an experiment. An event is any subset of the sample space — a collection of outcomes we care about.

For a die: Ω = {1, 2, 3, 4, 5, 6}. The event "roll an odd number" = {1, 3, 5}. Its probability is 3/6 = 1/2.

Key property: all probabilities in a sample space must sum to exactly 1. Something always happens.

Events can be combined with set operations: the union A ∪ B ("A or B"), the intersection A ∩ B ("A and B"), and the complement Aᶜ ("not A").

P(Aᶜ) = 1 − P(A)

Demo 2 · Die roll explorer

Live

Select an event and roll to see how outcomes are classified.

🎲
Choose an event and roll the die.
Quick check

Complements

If P(rain tomorrow) = 0.3, what is P(no rain tomorrow)?
A 0.3
B 0.6
C 0.7
D Cannot be determined
03

The addition rule

The probability that event A or event B occurs is given by the addition rule:

P(A ∪ B) = P(A) + P(B) − P(A ∩ B)

We subtract the intersection because outcomes in both A and B would otherwise be counted twice. If A and B are mutually exclusive (they can't both happen), then P(A ∩ B) = 0 and the rule simplifies to P(A ∪ B) = P(A) + P(B).

!
Common mistake: forgetting to subtract the overlap. "Rolling a 2 or an even number" — {2} is already inside {2,4,6}, so P(2 or even) = P(even) = 0.5, not 1/6 + 3/6.

Two events are independent when knowing one occurred tells you nothing about the other. For independent events: P(A ∩ B) = P(A) · P(B).

Demo 3 · Addition rule calculator

Live

Adjust P(A), P(B), and their overlap to see the addition rule in action.

Quick check

Addition rule

P(A) = 0.4, P(B) = 0.5, P(A ∩ B) = 0.2. What is P(A ∪ B)?
A 0.9
B 0.7
C 0.2
D 1.1
04

Conditional probability

Conditional probability answers: "given that B happened, how likely is A?" We write this P(A | B), read "probability of A given B."

P(A | B) = P(A ∩ B) / P(B)

This makes sense geometrically: we've restricted our universe to the outcomes inside B. Now we ask what fraction of those outcomes are also in A.

i
Independence, precisely: A and B are independent if and only if P(A | B) = P(A). Knowing B happened doesn't change A's probability at all.

From the definition we get the multiplication rule: P(A ∩ B) = P(A | B) · P(B). This is one of the most-used identities in all of probability.

Demo 4 · Conditional probability: marbles

Live

Draw marbles from a bag and explore conditional probability.

Quick check

Conditional probability

A bag has 3 red and 7 blue marbles. You draw one (it's red). What's P(red | first was red), drawing without replacement?
A 2/9
B 3/10
C 1/3
D 1/2
05

Bayes' theorem

Bayes' theorem lets us reverse conditional probabilities. We know P(B | A) — perhaps it's easy to measure — but we want P(A | B), which is often the more useful quantity.

P(A | B) = P(B | A) · P(A) / P(B)

P(A) is the prior — what we believed before seeing B. P(A | B) is the posterior — our updated belief after seeing B. Bayes' theorem is the engine of rational belief update.

Classic example: A medical test is 99% accurate. The disease affects 1% of the population. If you test positive, you might think P(disease | positive) ≈ 99%. Actually it's about 50%. Run the demo to see why.

Demo 5 · Bayes' theorem: medical test

Live

Adjust the sliders to see how prior probability and test accuracy combine.

P(disease | positive)
Quick check

Bayes' theorem

In Bayes' theorem, P(A) is called the _____ probability.
A Posterior
B Likelihood
C Prior
D Marginal
06

Distributions

A probability distribution describes how probability is spread across all possible outcomes. For discrete outcomes (like die faces) we use a probability mass function (PMF). For continuous outcomes (like heights) we use a probability density function (PDF).

Two of the most important discrete distributions:

Binomial(n, p) — the number of successes in n independent trials, each with success probability p. Rolling a 6 exactly 3 times in 10 dice rolls follows a binomial distribution.

P(X = k) = C(n, k) · pᵏ · (1−p)ⁿ⁻ᵏ

Expected value E[X] = Σ x · P(X = x) — the long-run average outcome. For a fair die: E[X] = (1+2+3+4+5+6)/6 = 3.5.

Demo 6 · Binomial distribution

Live

See how the distribution of successes changes with n and p.

Quick check

Expected value

A game pays $10 with probability 0.1 and $0 otherwise. What is the expected value per play?
A $0.10
B $1.00
C $10.00
D $5.00
07

Law of large numbers

The Law of Large Numbers (LLN) says that as the number of trials grows, the sample mean converges to the true expected value. The more you repeat an experiment, the less luck matters.

This is not the gambler's fallacy. The LLN does not say that after a long run of heads, tails is "due." Each flip is independent. The law operates through dilution — later flips don't correct earlier ones; they simply outnumber them.

i
Two versions: the weak LLN says the sample mean converges in probability. The strong LLN says it converges almost surely (with probability 1). Both hold for IID random variables with finite mean.

Demo 7 · Law of large numbers

Live

Watch the running proportion of heads converge to 0.5 over many flips.

Press "Run 500 flips" to watch convergence.
Final boss

Law of large numbers

After flipping heads 10 times in a row, what does the Law of Large Numbers say about the next flip?
A Tails is now more likely
B Heads is more likely (momentum)
C The next flip is guaranteed tails
D The next flip is still 50/50

Glossary