Grounds probability basics, conditional probability, Bayes' rule, and expectation for ML readers.
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.
Intuition
The idea in plain words, before the symbols.
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 .
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.
One caution: probability is not only long-run frequency. In Bayesian inference it can also represent degrees of belief about unknowns. Under either reading, the same rules for events, conditioning and normalization apply.
Study prompts for this section: Intuition
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Mathematics
Definitions, assumptions and the derivation.
For this page, start with a finite probability model. A probability space is :
- : sample space (all outcomes)
- : events (in a finite model, usually all subsets of ; in general, a sigma-algebra of measurable subsets)
- : probability measure
For events , the basic axioms are:
- If are pairwise disjoint, then
For finite examples, this reduces to adding the probabilities of disjoint pieces.
The complement rule follows:
Conditional probability means updating probabilities after observing an event :
The denominator matters. Conditioning does not merely keep ; it rescales all probability inside so the new total mass is . If , there is no mass inside the observed event to renormalize, so is undefined.
The product rule is the same equation rearranged:
when the conditioning events have positive probability.
Independence means learning one event does not change the probability of the other:
Equivalently, when , independence means .
Bayes' rule follows by writing the same intersection two ways:
If are mutually exclusive hidden cases that cover the sample space, they form a partition. The denominator can be expanded by total probability:
for hidden cases with positive prior probability.
That gives the form used in classification, diagnosis, and Bayesian updating:
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 is the observed Head or Tail.
Study prompts for this section: Mathematics
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Code
The same calculation as runnable code, in the notation of the derivation.
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))
Study prompts for this section: Code
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Demo
Change an input, predict the result, and see which quantities respond.
Explore Probability Basics
Observation guide
Optional and ungraded. Opening a guide saves nothing.
Choose what to inspect in Probability Basics, then open its guide.
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 and . When Tail is observed, the likelihoods are and .
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.
Study prompts for this section: Demo
Each button copies a prompt about this section to your clipboard, for an AI assistant you already use. Nothing is sent by this site.
Concept: Probability Basics
What is the smallest example of Probability Basics you can work through by hand, and what does it show?
DetailsProbability
Reference id
concept:probability/probability-basicsAfter the first pass
Go deeper
Optional material for a second reading. Sources are always shown; the other panels open from their headings or from these links, and closing one keeps what you wrote or revealed.What to look for in each sectionChoose a section and what you expect to see in it, then read short advice.
Section by section
Choose what to look for in each section
Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.

Start with the picture, metaphor, or geometric mechanism.
Choose what you expect to see in this section of Probability Basics.
Questions to ask of the pictureChoose a part of the picture and what you expect, then read short advice.
Looking at the picture
Questions to ask of the picture
Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.
Which part of the picture should you look at first?
Pick the part of the picture you expect to explain Probability Basics.
Sources
References for this page
A reference shows where an idea comes from; it does not vouch for every step on this page.Springer; in English as Foundations of the Theory of Probability (Chelsea, 1950). States the axioms of probability on a sample space and defines conditional probability.
Chapman & Hall/CRC. Chapters 1 and 2 cover sample spaces, the axioms, conditional probability, independence and Bayes' rule with the law of total probability.
What each claim rests on1 claim, each with its sources, where it appears on this page, and its caveats.
Claims and sources
Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.
The checks were made by this site, not by an independent reviewer.
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...
This checks the finite-event probability and conditioning bridge used here, not continuous regular conditional probabilities or philosophical interpretations of probability.
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.
Explain it without the pageWrite your own explanation before asking for feedback. Your draft and any hints stay while this page is open.
Practice · Probability Basics
Try the idea in your own words
Events are subsets of a sample space, and probabilities obey a few axioms; from there you get conditional probability, independence, and Bayes' rule.
Concept · Selected for practice
Probability Basics
What it rests on: Sources: Mathematics for Machine Learning; Grundbegriffe der Wahrscheinlichkeitsrechnung; Introduction to Probability (2nd ed.)
Context and links
Probability
Explain the mechanism
For Probability Basics: What is the smallest example of Probability Basics you can work through by hand, and what does it show? Explain your answer, including what changes, why, and which assumption matters.
A rough first thought is enough. Your draft stays when you change tasks.
Your draft stays on this page and is cleared when you leave or reload.
A little help · Explain
Open one hint at a time. These are suggestions, not your answer or a grade.
0 of 3 hints shown for this question.
Clearing your answer keeps this help record. Outside help is your own report; this page cannot check it.
Where am I stuck? (optional)
Take your draft to a feedback conversation
No AI feedback runs here. You can copy a prompt to use elsewhere; nothing is sent automatically. Review the text before sharing, and leave out private information.
Write an attempt before copying a feedback prompt.
A draft, or an AI reply to it, is not a test of what you have learned. To check that, try a different case later without help.
Ask about this pagePick one item on this page and copy a prompt about it into an AI assistant you already use. Notes you write here stay in this browser.
assert abs(sum(joint.values()) - 1.0) < 1e-12Your question
Choose what your question is about
Pick the idea, equation, source, code, claim, misconception or demo state you want to ask about. The prompt you copy includes it, so the answer can stay on that item.Open the draft below to save one note and next action in this browser.
Probability Basics
What is the smallest example of Probability Basics you can work through by hand, and what does it show?
Fixed prompts generated from this item. They are not comments from people or independent reviews.
The 3 cited sources must support this exact item, not just the surrounding topic.
Connect the definition to one equation, piece of code or demo before widening the discussion.
Change one input, then check that the same relationship holds in the mathematics, the code and the demo.
You can state the mechanism in your own words
Local action draftNo local draft saved yetOpen when you are ready to write one next action
This draft stays in this browser and is attached to this item only.
- What the 3 cited sources say about this exact item
- The definition, its prerequisites, and a contrasting concept
- The equation or code that makes the concept concrete
- One demo state that shows what stays the same as the inputs change
- You can state the mechanism in your own words
- You can name the prerequisite that would clear up the confusion
- You can predict how the result changes when one input changes
Reference id
concept/concept-notebook/probability/probability-basics
concept:probability/probability-basics