Concept notebookChecking saved investigationReading browser-local route memory before showing a continuation.

Probability Basics

Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.

published · difficulty 1/5 · 12 min read

01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

PredictName the object in plain language, then predict what should change.Leave with one reusable mental picture before notation appears.

You see one outcome, but you do not see the hidden situation that produced it. How should your belief change?

Probability starts by listing possible worlds and assigning mass to sets of worlds. An event is a subset of those worlds. Conditional probability is what happens when you learn that the true world lies inside one event: you keep only the compatible worlds and renormalize their mass back to 111.

This "filter then renormalize" picture is the foundation for likelihood, Bayesian inference, calibration, uncertainty, and losses such as cross-entropy. In machine learning, a model is often a device that assigns probabilities to possible observations or labels. The first question is not whether the model is deep; it is whether its probability statements obey the basic rules.

The analogy has a limit: probability is not only long-run frequency. In Bayesian inference it can also represent degrees of belief over unknowns. What stays invariant is the algebra of events, conditioning, and normalization.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

InspectTrack the same object through the notation and check each symbol.Leave with the invariant the equations preserve.

For this page, start with a finite probability model. A probability space is (Ω,F,P)(\Omega,\mathcal F,P)(Ω,F,P):

  • Ω\OmegaΩ: sample space (all outcomes)
  • F\mathcal{F}F: events (in a finite model, usually all subsets of Ω\OmegaΩ; in general, a sigma-algebra of measurable subsets)
  • PPP: probability measure

For events EFE\in\mathcal FEF, the basic axioms are:

  1. P(E)0P(E) \ge 0P(E)0
  2. P(Ω)=1P(\Omega)=1P(Ω)=1
  3. If E1,E2,E_1,E_2,\dotsE1,E2, are pairwise disjoint, then
P(iEi)=iP(Ei).P\left(\bigcup_i E_i\right)=\sum_i P(E_i).P(iEi)=iP(Ei).

For finite examples, this reduces to adding the probabilities of disjoint pieces.

The complement rule follows:

P(Ec)=1P(E).P(E^c)=1-P(E).P(Ec)=1P(E).

Conditional probability means updating probabilities after observing an event OOO:

P(EO)=P(EO)P(O)(P(O)>0).P(E\mid O) = \frac{P(E\cap O)}{P(O)} \quad (P(O)>0).P(EO)=P(O)P(EO)(P(O)>0).

The denominator matters. Conditioning does not merely keep EOE\cap OEO; it rescales all probability inside OOO so the new total mass is 111. If P(O)=0P(O)=0P(O)=0, there is no mass inside the observed event to renormalize, so P(EO)P(E\mid O)P(EO) is undefined.

The product rule is the same equation rearranged:

P(EO)=P(EO)P(O)=P(OE)P(E),P(E\cap O)=P(E\mid O)P(O)=P(O\mid E)P(E),P(EO)=P(EO)P(O)=P(OE)P(E),

when the conditioning events have positive probability.

Independence means learning one event does not change the probability of the other:

EO    P(EO)=P(E)P(O).E \perp O \iff P(E\cap O)=P(E)P(O).EOP(EO)=P(E)P(O).

Equivalently, when P(O)>0P(O)>0P(O)>0, independence means P(EO)=P(E)P(E\mid O)=P(E)P(EO)=P(E).

Bayes' rule follows by writing the same intersection two ways:

P(EO)=P(OE)P(E)P(O).P(E\mid O) = \frac{P(O\mid E)P(E)}{P(O)}.P(EO)=P(O)P(OE)P(E).

If C1,,CmC_1,\dots,C_mC1,,Cm are mutually exclusive hidden cases that cover the sample space, they form a partition. The denominator can be expanded by total probability:

P(O)=j=1mP(OCj)P(Cj),P(O)=\sum_{j=1}^m P(O\mid C_j)P(C_j),P(O)=j=1mP(OCj)P(Cj),

for hidden cases with positive prior probability.

That gives the form used in classification, diagnosis, and Bayesian updating:

P(CiO)=P(OCi)P(Ci)j=1mP(OCj)P(Cj).P(C_i\mid O)=\frac{P(O\mid C_i)P(C_i)}{\sum_{j=1}^m P(O\mid C_j)P(C_j)}.P(CiO)=j=1mP(OCj)P(Cj)P(OCi)P(Ci).

The numerator is likelihood times prior. The denominator is the total evidence. In the demo, the hidden cases are "coin A was chosen" and "coin B was chosen," while OOO is the observed Head or Tail.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

TraceMatch variables to symbols before reading the implementation.Leave with a runnable witness for the math.
import numpy as np

rng = np.random.default_rng(0)

# Hidden state: choose coin A or coin B, then observe Head or Tail.
prior_B = 0.30
p_head_A = 0.20
p_head_B = 0.80

prior_A = 1 - prior_B

joint = {
    ("A", "H"): prior_A * p_head_A,
    ("A", "T"): prior_A * (1 - p_head_A),
    ("B", "H"): prior_B * p_head_B,
    ("B", "T"): prior_B * (1 - p_head_B),
}

assert abs(sum(joint.values()) - 1.0) < 1e-12

# Bayes numerator = likelihood times prior.
bayes_numerator = p_head_B * prior_B
evidence_H = p_head_A * prior_A + p_head_B * prior_B
posterior_B_given_H = bayes_numerator / evidence_H

assert abs(bayes_numerator - joint[("B", "H")]) < 1e-12
assert abs(evidence_H - (joint[("A", "H")] + joint[("B", "H")])) < 1e-12

print("P(H):", round(evidence_H, 3))
print("P(B and H):", round(joint[("B", "H")], 3))
print("P(H | B)P(B):", round(bayes_numerator, 3))
print("P(B | H):", round(posterior_B_given_H, 3))

# Monte Carlo check: simulate the same process.
n = 200_000
is_B = rng.random(n) < prior_B
head_probability = np.where(is_B, p_head_B, p_head_A)
heads = rng.random(n) < head_probability
print("simulation P(B | H):", round(is_B[heads].mean(), 3))
Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

ManipulateChange one control and predict the visible response before reveal.Leave with the observed invariant or a repaired model.

Live Concept Demo

Explore Probability Basics

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 1/5highschoolcode-aligned
Demo inquiry checkpoint

Manipulate one control and predict the visible change.

01Choose lensTrace a quantity
02ObserveDemo state pending
03GroundName the equation, invariant, or control that explains it.
04CarryNext: Random Variables

Choose what to inspect in Probability Basics. This shared fallback is an observation guide, not evidence of learning.

Loading interactive demo...

Move the prior and likelihood sliders, then switch the observation between Head and Tail. After you reveal, the table shows the four joint probabilities. Conditioning keeps the column matching the observation and renormalizes it.

When Head is observed, the likelihoods are P(HA)P(H\mid A)P(HA) and P(HB)P(H\mid B)P(HB). When Tail is observed, the likelihoods are P(TA)=1P(HA)P(T\mid A)=1-P(H\mid A)P(TA)=1P(HA) and P(TB)=1P(HB)P(T\mid B)=1-P(H\mid B)P(TB)=1P(HB).

Watch the base rate. A coin can be very good at producing heads, but if it is rare enough, observing heads may still leave uncertainty about which coin was chosen.

Section prompt

Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.

4/4 sections ready

Concept: Probability Basics

What is the smallest example that makes Probability Basics click without losing the math?

BeforeNo hard prerequisiteNow4/4 sections readyTryManipulate one control and predict the visible change.NextRandom Variables
Object contextProbability
ConceptLearner lens

Probability Basics

What is the smallest example that makes Probability Basics click without losing the math?

Mode questionCan I say the mechanism back in one sentence before I reveal anything?

Start with the prediction checkpoint, then compare the reveal to the mental model.

Take this move

Study modes

Keep the object fixed; change the lens.

Route back through the notebook

Carry the same object through intuition, math, code, and demo.

4/4 sections ready
Carry inNo hard prerequisite

This page can stand on its own, so the first job is to build the mental picture carefully.

Work hereProbability Basics

Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.

Carry outRandom Variables

The next edge should feel earned: use the demo prediction here before following Random Variables.

After The First Pass

Turn the concept into an inspected object.

The lower panels are one second act: keep the object fixed, inspect it visually, check source boundaries, practice transfer, then attach the research question.
ConceptProbability BasicsProbability

Mechanism Storyboard

See the idea move before the page explains it

Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.

Demo notes open01 / Intuition
Editorial probability illustration of a sample space, overlapping event regions, probability mass, and conditional renormalization cues.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Probability Basics should make visible.

Visual Inquiry

Make the image answer a mathematical question

Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.

4/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Probability Basics easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

Object - ConceptProbability BasicsQuestion

What is the smallest example that makes Probability Basics click without losing the math?

concept:probability/probability-basics
Boundary

sources: deisenroth-2020-mml

Check

Open the closest source note before trusting the local explanation.

Evidence

1 selected-object source shown first; 1 reference total.

Next move

Audit the claim boundary, then ask from the same selected object.

selected object source · book · 2020Mathematics for Machine LearningDeisenroth, Faisal, and Ong
Located CF editorial boundary

Grounds probability basics, conditional probability, Bayes' rule, and expectation for ML readers.

Used here as

Mathematics for Machine Learning introduces probability for ML through probability spaces, events, conditional probability, independence, Bayes' theorem, and expectation, matching this pa...

Caveat

This checks the finite-event probability and conditioning bridge used here, not continuous regular conditional probabilities or philosophical interpretations of probability.

Open source

Claim Review

Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.

Object - ConceptProbability BasicsQuestion

What is the smallest example that makes Probability Basics click without losing the math?

concept:probability/probability-basics
Boundary

sources: deisenroth-2020-mml

Check

Treat every claim as provisional until source support and a local witness agree.

Evidence

1 structured claim check on this concept.

Next move

Run the prediction or practice transfer before asking for a grounded review.

1 CF editorial source-scope review recorded

Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 1 reference and 3 local witnesses are available for inspection.

In a finite probability model, events are subsets of a sample space whose probabilities are nonnegative, add over disjoint unions, total one on the whole space, and get renormalized when conditioning on observed evidence.
Used here as

Mathematics for Machine Learning introduces probability for ML through probability spaces, events, conditional probability, independence, Bayes' theorem, and expectation, matching this page's finite-event an...

Local witness
Equation 1
P(iEi)=iP(Ei).P\left(\bigcup_i E_i\right)=\sum_i P(E_i).
Equation 2
P(Ec)=1P(E).P(E^c)=1-P(E).
Caveat

This checks the finite-event probability and conditioning bridge used here, not continuous regular conditional probabilities or philosophical interpretations of probability.

Review stateCF editorial source-scope reviewClaim metadata: source checkedPublisher-side editorial review only; not independent replication. Check caveats and exact source scope.

Checked MML chapter 6.1-6.3: it defines the sample space as all outcomes, event space as subsets of Omega, assigns each event A a probability P(A) in [0,1], and requires total mass P(Omega)=1. Its finite coin example adds the probabilities of disjoint outcomes in a union, section 6.2 defines conditional probabilities as table fractions, and section 6.3 derives Bayes' rule with evidence normalizing the posterior.

Reviewer: codex+oracle; reviewed 2026-05-06

Practice notebook

Use the idea, then test it somewhere new

Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.

AttemptNo learning claim inferred
Object - ConceptProbability BasicsQuestion

What is the smallest example that makes Probability Basics click without losing the math?

concept:probability/probability-basics
Boundary

sources: deisenroth-2020-mml

Check

Use one state from Probability Basics to explain what changes, why it changes, and which assumption the explanation needs.

Evidence

No learner move yet; no learning state is inferred.

Next move

Write first, use only the help you need, then try a new case without it.

Explain

Use one state from Probability Basics to explain what changes, why it changes, and which assumption the explanation needs.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Grounded object roomClose
Selected object routeAsk from this object; carry one invariant back.sources: deisenroth-2020-mml
  1. ObjectConceptProbability Basics
  2. PredictBefore revealProbability Basics prediction
  3. WitnessCompare codeProbability Basics code witness 1
  4. RoomAsk groundedChecking local snapshot
ConceptProbability BasicsProbability

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptProbability

Probability Basics

Anchored question

What is the smallest example that makes Probability Basics click without losing the math?

Source boundaryInspect source ids: deisenroth-2020-mmlStable content-object key attached
Role lenses for this object

These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.

Learner evidence requestAsk what would make "Probability Basics" feel predictable rather than familiar.
Assumption

Source ids deisenroth-2020-mml must support the exact object, not just the surrounding topic.

Source-checking summary

Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.

Proposed experiment

Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.

Next action

The learner can state the mechanism in their own words

Evidence4 checks
PredictionChecking carried observation
ActionReady for one action
AILearner handoff ready
Open source object
01PredictionChecking browser-local route memory
02EvidenceChecking for a carried observation
03BoundaryInspect source ids: deisenroth-2020-mml
04Next moveSave one next action
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:probability/probability-basics.

No local draft saved.
Evidence to inspect
  • Source ids to inspect: deisenroth-2020-mml
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Object-attached AI handoff

I am working in Continuous Function's research reading room. Object: concept - Probability Basics Object key: concept:probability/probability-basics Context: Probability Anchor id: concept/concept-notebook/probability/probability-basics Open question: What is the smallest example that makes Probability Basics click without losing the math? Evidence to inspect: - Source ids to inspect: deisenroth-2020-mml - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan Deterministic role lenses for this object: - Boundary: fixed perspectives, not people, community contributions, or independent review - Source-checking summary: Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Teach/transfer move: Turn the mechanism into one sentence that predicts a neighboring concept. - Assumptions: - Source ids deisenroth-2020-mml must support the exact object, not just the surrounding topic. - The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. - The concept explanation is local atlas prose until checked against its math, code, and source support. - Prerequisite gaps should become a repair route, not a reason to leave the object vague. - Role-lens requests: - Learner: ask for "Ask what would make "Probability Basics" feel predictable rather than familiar." | assumption: Source ids deisenroth-2020-mml must support the exact object, not just the surrounding topic. | next action: The learner can state the mechanism in their own words - Researcher: ask for "Source ids to inspect: deisenroth-2020-mml" | assumption: The stable content-object key lets local drafts, prompts, and route memory attach without changing the source page. | next action: The learner can name the prerequisite that would repair confusion - Experimenter: ask for "Choose one variable or condition to perturb before asking for an explanation." | assumption: The concept explanation is local atlas prose until checked against its math, code, and source support. | next action: The learner can predict how the mechanism changes under one perturbation - Professor: ask for "Find the smallest transferable rule a learner could reuse without the AI." | assumption: Prerequisite gaps should become a repair route, not a reason to leave the object vague. | next action: Teach or transfer: Turn the mechanism into one sentence that predicts a neighboring concept. What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action. Current deterministic role lens for this object: - Role lens: Learner - Evidence request: Ask what would make "Probability Basics" feel predictable rather than familiar. - Assumption to keep visible: Source ids deisenroth-2020-mml must support the exact object, not just the surrounding topic. - Proposed experiment: Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo. - Next action: The learner can state the mechanism in their own words

concept/concept-notebook/probability/probability-basics concept:probability/probability-basics