Part I · Terminology, Events & Random Variables
Section 01

Terminology in Probability

Five words carry the whole subject. A random experiment produces an outcome; collect all outcomes and you have the sample space; pick some of them and you have an event.

Random Experiment

A process that produces an outcome.

Outcome

A result of a single trial.

Trial

A single performance of an experiment.

Event

A subset of the sample space (specific outcomes).

ExamplesRolling an even number: {2, 4, 6}
Getting heads: {H}
Drawing a heart: {13 heart cards}
Sample Space

The set of all possible outcomes of an experiment.

ExamplesDice: S = {1, 2, 3, 4, 5, 6}
Coin: S = {H, T}
Cards: S = {52 cards}
Relationship

Key connections between terms: a trial produces an outcome; outcomes live in the sample space; an event groups outcomes we care about.

Section 02

Types of Events

Impossible & Sure Events

Events with probability 0 (impossible) and 1 (sure).

ExamplesImpossible: rolling a 7 on a standard die (P = 0)
Sure: getting a number between 1–6 on a die (P = 1)
Simple Events

Events consisting of a single outcome from the sample space.

ExamplesRolling a 4 on a die: {4}
Getting heads on a coin flip: {H}
Drawing the ace of spades
Compound Events

Events consisting of more than one outcome from the sample space.

ExampleRolling an even number on a die: {2, 4, 6}
Independent & Dependent Events

Events that do not affect (independent) or do affect (dependent) each other.

ExamplesTwo coin flips — independent. Drawing cards without replacement — dependent.
Mutually Exclusive Events

Events that cannot occur simultaneously (no common outcomes).

ExamplesGetting heads and tails on a single coin flip
Rolling a 2 and a 5 on a single die
Drawing a heart and a spade in one draw
Exhaustive Events

A set of events that together cover the entire sample space.

ExamplesOn a die: {1,2,3} and {4,5,6}
Coin: {H} and {T}
Cards: {red cards} and {black cards}
Complementary Events

Events that are complements of each other (E and E′). P(E) + P(E′) = 1.

ExampleRolling a 6 and not rolling a 6.
OR (Union) & AND (Intersection)

OR: event A ∪ B (A or B or both). AND: event A ∩ B (A and B together).

ExamplesOR: rolling an even number or a 5: {2, 4, 5, 6}
AND: rolling even and greater than 3: {4, 6}
Section 03

What Is Probability

Probability is the measure of the likelihood that an event will occur.

P(E) = Number of Favorable OutcomesTotal Number of Outcomes

Properties

0 ≤ P(E) ≤ 1  ·  P(S) = 1 (the sample space is certain)  ·  P(∅) = 0 (the empty set is impossible).

Dice

P(rolling a 4) = 1/6

Coin

P(getting heads) = 1/2

Cards

P(drawing an ace) = 4/52 = 1/13

Dice

P(rolling an even number) = 3/6 = 1/2

Section 04

Empirical vs Theoretical Probability

Empirical (Experimental) Probability

Based on observations during an experiment.

FormulaP(E) = times event occurs / total trials
Theoretical Probability

Based on reasoning or formulas, without conducting an experiment.

FormulaP(E) = favorable outcomes / possible outcomes

Comparison example — rolling a die 50 times, counting sixes

TypeCalculationResult
Empirical8 sixes / 50 rolls0.16 (16%)
Theoretical1 face / 6 faces0.167 (16.7%)
Law of Large Numbers

As the number of trials increases, empirical probability approaches theoretical probability. With few trials they may differ significantly; with many trials the empirical value converges.

Interactive — Watch the Law of Large Numbers FLIP A FAIR COIN · WATCH THE RUNNING PROPORTION SETTLE AT 0.5
No flips yet — start flipping.running proportion of heads vs. theoretical 0.5
Section 05

Random Variables

A random variable is a variable whose possible values are numerical outcomes of a random phenomenon.

Discrete Random Variables

Countable outcomes that can be listed or enumerated.

ExamplesHeads in 3 coin flips: {0, 1, 2, 3}
Number on a die: {1, 2, 3, 4, 5, 6}
Customers in a store: {0, 1, 2, 3, …}
Defective items in a batch: {0, 1, 2, …, n}
Continuous Random Variables

Uncountable outcomes that can take any value within an interval.

ExamplesHeight of a person: any value within a range
Time until next bus: any non-negative value
Temperature: any value within a range
Weight of a product: within a tolerance range
Key Differences

Discrete: probability of specific values > 0, described by a Probability Mass Function (PMF).
Continuous: probability of any exact value = 0, described by a Probability Density Function (PDF).

Section 06

Probability Distributions — PMF, PDF & CDF

A probability distribution describes the likelihood of different possible values of a random variable. All probabilities lie between 0 and 1, and they sum to 1. Common shapes: Binomial, Normal, Uniform, Poisson.

Think of the three functions as three ways of looking at the same distribution: lumps of probability at points (PMF), a density spread across a continuum (PDF), and probability accumulating as you move along the number line (CDF).

Interactive — Three Views of One Distribution HOVER THE BARS
PMF — Probability Mass

P(X = x) = f(x). Used for discrete variables; probability of exact values > 0; visualized as bars.

PDF — Probability Density

P(a ≤ X ≤ b) = ∫ab f(x) dx. Used for continuous variables; probability of exact values = 0; visualized as a smooth curve — probability is area.

CDF — Probability Volume Filled

F(x) = P(X ≤ x). Values range from 0 to 1; non-decreasing; visualized as an S-shaped (step) curve.

Section 07

Mean & Variance of a Random Variable

Mean (Expected Value)

The weighted average of the possible values of a random variable.

Formulaμ = Σ (x × P(x))
x = each value · P(x) = its probability · Σ = sum over all values
Variance & Standard Deviation

How spread out the values are around the mean. Standard deviation σ is the square root of the variance.

Formulasσ² = Σ[(x − μ)² × P(x)]
σ² = E[X²] − (E[X])²

Worked example — rolling a fair die

1
Mean — each face has probability 1/6
μ = (1+2+3+4+5+6) × (1/6) = 21/6 = 3.5
2
E[X²] — square each face first
E[X²] = (1+4+9+16+25+36) × (1/6) = 91/6 ≈ 15.17
3
Variance
σ² = 15.17 − (3.5)² = 91/6 − 49/4 ≈ 2.92
4
Standard deviation
σ = √2.92 ≈ 1.71

Interpretation: over many rolls, the average converges to 3.5, and outcomes typically sit about 1.71 away from that mean.

Part II · Venn Diagrams, Contingency Tables — Joint, Marginal & Conditional Probability
Section 08

Venn Diagrams

A Venn diagram is a visual tool using circles to represent sets, showing relationships between events and probabilities.

Components

Universal set: contains all possible outcomes.
Event sets: circles representing specific events.
Intersection: overlapping area for simultaneous events.

Probability Calculation

Compare the area of regions to the total area: P(A) = Area of A / Total Area.

Venn diagrams visualize event relationships, simplify complex probability calculations, and make joint and conditional probabilities intuitive — as you will see below.

Interactive — Venn Diagram Explorer DRAG THE SLIDERS · CLICK A REGION BUTTON
A B 0.30 0.10 0.25 outside: 0.35
0.30
0.10
0.25

The addition rule hides inside the diagram: P(A ∪ B) = P(A) + P(B) − P(A ∩ B) — add the circles, then subtract the double-counted overlap. Drag P(A ∩ B) to zero and the events become mutually exclusive.

Section 09

Contingency Tables

A contingency table shows relationships between two or more categorical variables — also called a cross-tabulation. Rows are categories of one variable, columns of another, and cells hold frequency counts for specific combinations.

The three readings of one table

Joint probability: cell value ÷ grand total.
Marginal probability: row/column total ÷ grand total.
Conditional probability: cell value ÷ row/column total  →  P(A|B) = P(A∩B) / P(B).

The table below is a real survey: 223 customers classified by gender and computer purchase. It is fully editable — change any count and every total, marginal, joint and conditional probability updates live. The next three sections each use one mode of this same lab.

Contingency Table Explorer — Gender × Computer Purchase CLICK A CELL
counts ↓ PC Mac Row Totals
Male
Female
Column Totals

Applications: market research, medical diagnosis, risk assessment, social surveys, data analysis.

Section 10

Joint Probability

The probability of two or more events occurring simultaneously — the overlap of the Venn diagram, a single cell of the table.

P(A ∩ B) = P(A) × P(B) independent events P(A ∩ B) = P(A | B) × P(B) general case — joint = conditional × marginal

Calculation methods

Venn diagram: overlapping area ÷ total area. Contingency table: cell value ÷ total — in our survey, P(Male ∩ PC) = 66/223 ≈ 0.296.

Example

Rolling two dice, probability of both being 6: P(6 ∩ 6) = 1/6 × 1/6 = 1/36 (independent rolls).

Open the lab in Joint mode →

Section 11

Marginal Probability

The probability of a single event occurring, without considering other events. It lives in the margins of the table — the row and column totals.

P(A) = Σ P(A ∩ Bi)    P(B) = Σ P(Ai ∩ B) sum the joint probabilities over every level of the other variable

Calculation methods

Venn diagram: single circle area ÷ total area. Contingency table: row/column total ÷ total.

Example — gender and purchase behavior table

P(Female) = Female row total / Total = 117/223 ≈ 0.525. Likewise P(PC) = 96/223 ≈ 0.430 and P(Mac) = 127/223 ≈ 0.570.

Open the lab in Marginal mode →

Section 12

Conditional Probability

The probability of one event occurring given that another event has already occurred. The given information shrinks the universe: only the outcomes inside the conditioning event still count.

P(A | B) = P(A ∩ B)P(B)    P(B | A) = P(A ∩ B)P(A) conditional = joint ÷ marginal

Calculation methods

Venn diagram: overlapping area ÷ area of the given circle. Contingency table: cell value ÷ row/column total.

Example — gender and purchase behavior table

P(Mac | Female) = 87/117 ≈ 0.744 — the probability of buying a Mac, given the customer is female.

Interactive — The Universe Shrinks 89 OUTCOMES: 17 B-ONLY · 13 BOTH · 14 C-ONLY · 45 OUTSIDE · CHOOSE WHAT IS “GIVEN”
B only (17) B ∩ C (13) C only (14) outside (45)

Open the lab in Conditional mode →

Section 13

How the Three Connect

Core Relationship

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

Conditional = Joint ÷ Marginal

Probability Transformation

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

Joint = Conditional × Marginal

Law of Total Probability

P(A) = Σ P(A|Bi) × P(Bi)

Marginal = weighted sum of conditionals

Real-World Applications

Medical diagnosis: predicting disease probability from symptoms.
Market analysis: customer purchase behavior prediction.
Risk assessment: financial and insurance risk modeling.

Decision Support Tools

Bayesian inference: updating beliefs with new evidence.
Machine learning: foundation for classification algorithms.
Data mining: discovering hidden relationships in data.

Section 14

Bayes' Theorem

P(A|B) = P(B|A) × P(A)P(B) Alternative form: P(A|B) = P(B|A)×P(A) / [P(B|A)×P(A) + P(B|¬A)×P(¬A)]

Core principle: it inverts conditional probability. Key insight: it updates beliefs with new evidence.

Prior Probability — P(A)

Initial belief before evidence.

Likelihood — P(B|A)

Probability of the evidence if the hypothesis is true.

Posterior Probability — P(A|B)

Updated belief after seeing the evidence.

Evidence — P(B)

Normalizes the calculation (via the law of total probability).

Connection to other concepts

Joint probability: P(A∩B) = P(B|A)×P(A).  Conditional probability: inverts P(A|B) to find P(B|A).  Marginal probability: P(B) comes from the law of total probability.

Medical diagnosis — the classic scenario

A test for a rare disease: 1% prevalence, 99% true-positive rate, 2% false-positive rate. If your test comes back positive, what is the probability you actually have the disease? The answer surprises almost everyone — drag the sliders to see why.

Interactive — Bayes' Theorem Calculator P(DISEASE | POSITIVE TEST) = ?
1.0%
99%
2.0%

DEFAULTS MATCH THE SLIDE: 1% prevalence · 99% sensitivity · 2% false-positive rate

Out of 1,000 people: about 10 have the disease (9.9 test positive), but about 20 healthy people also test positive — so a positive result means only ≈ 1/3 chance of disease. The rareness of the disease (the prior) dominates.

Section 15

Bayes' Theorem Example — Titanic Survival

Question: what is the probability that a passenger survived, given they were in first class?

Passenger ClassSurvivedNot SurvivedTotal
1st Class203122325
2nd Class118167285
3rd Class178528706
Total4998171316
P(Survived | 1st Class) = P(1st Class | Survived) × P(Survived) / P(1st Class)
1
Calculate P(Survived)
P(Survived) = 499/1316 ≈ 0.379
2
Calculate P(1st Class)
P(1st Class) = 325/1316 ≈ 0.247
3
Calculate P(1st Class | Survived)
P(1st Class | Survived) = 203/499 ≈ 0.407
4
Apply Bayes' theorem
P(Survived | 1st Class) = 0.407 × 0.379 / 0.247 ≈ 0.624 = 62.4%
Interpretation

First-class passengers had a 62.4% chance of survival — significantly higher than the overall survival rate of 37.9%. (Check it directly from the table: 203/325 ≈ 0.625 — Bayes gets the same answer by inverting the conditional.)

Summary

Key Concepts & Formula Sheet

Key Concepts

✓ Venn diagrams: visualize event relationships and probabilities.
✓ Contingency tables: organize categorical data systematically.
✓ Joint probability: likelihood of multiple events occurring together.
✓ Marginal probability: likelihood of a single event occurring.
✓ Conditional probability: likelihood of one event given another.

Applications & Value

▸ Decision support: probability-based informed decision making.
▸ Risk assessment: quantify uncertainty, manage risks.
▸ Predictive modeling: build data-driven prediction systems.
▸ Scientific reasoning: foundation for Bayesian inference.

Probability
P(E) = favorable outcomes / total outcomes
Complement
P(E) + P(E′) = 1
Addition rule
P(A ∪ B) = P(A) + P(B) − P(A ∩ B)
Joint
P(A ∩ B) = cell / total  ·  = P(A|B) × P(B)
Marginal
P(A) = Σ P(A ∩ Bᵢ) — row/col total ÷ total
Conditional
P(A|B) = P(A ∩ B) / P(B)
Total probability
P(A) = Σ P(A|Bᵢ) × P(Bᵢ)
Bayes' theorem
P(A|B) = P(B|A) × P(A) / P(B)
PMF · PDF · CDF
P(X=x) · P(a≤X≤b)=∫f dx · F(x)=P(X≤x)
Mean & variance
μ = Σ x·P(x)  ·  σ² = E[X²] − (E[X])²