Bring the mental model from Random Variables; this page will reuse it instead of restarting from zero.
Distributions
A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.
01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
The raw outcome might be HH, HT, TH, or TT, but your model only records X= number of heads. So what is the probability of X=1?
A random variable is the measurement rule that turns each raw outcome into a value. A distribution is the probability measure induced on those values after the rule is applied.
The distinction is small but important. The world may have detailed outcomes: full coin-flip sequences, images, documents, users, or physical states. A random variable turns each outcome into a value we care about. The distribution tells us how probability lands on those values. "Measurement" is only a metaphor: X does not have to be a physical instrument, and the distribution is not the rule itself. It is the probability law created by applying the rule to uncertain outcomes.
Many different outcomes can map to the same value. If X is the number of heads in two coin flips, both HT and TH become X=1. The probability of X=1 is the combined probability of all outcomes that map there.
That is the bridge to modeling. Once you know the distribution of a random variable, you can sample from it, compute expectations, and score observations. Maximum likelihood will later ask which parameter setting makes the observed values most probable under a chosen distribution family.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let (Ω,F,P) be a probability space. Let (S,S) be the measurable space of values, and let
be a measurable random variable. The distribution, or law, of X is the probability measure PX on values:
Here A∈S is a measurable set of values. Equivalently, PX(A)=P(X−1(A)).
This is called the pushforward of P through X. It says: start with probability on raw outcomes, apply the measurement X, and add up the probability that lands inside each value-set A.
For a discrete random variable, the probability mass function is
If the raw sample space is finite, this is just the mass of every outcome that maps to x:
This is the central mechanism: a value collects probability from every raw outcome that maps to it. Grouping changes the representation of probability, not the total mass, so ∑xpX(x)=1.
When X is real-valued, the cumulative distribution function is
It accumulates the mass up to a threshold. For many real-valued distributions used in machine learning, PX has a density fX and interval probabilities are computed by integration:
A density value is not itself a probability; only area under the density over a region is probability. Density values can be greater than 1, because they depend on the units of x. Some distributions are mixed or have no ordinary density, so PMFs and densities are important cases, not the whole definition of distribution.
The demo uses two independent Bernoulli flips with head probability p and random variable X= number of heads. Then X has a binomial distribution:
Its expectation and variance are
In machine learning, a parametric distribution family writes this mass or density as pθ(x). If observed values x(1),…,x(n) are treated as independent draws from the distribution, the log likelihood is
For discrete data, pθ(x) is a probability mass. For continuous data, pθ(x) is a density value, so likelihood scores density at the observations; it is not the probability of observing those exact points.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import math
import numpy as np
p_head = 0.65
# Raw outcomes for two independent flips.
outcomes = {
"HH": p_head * p_head,
"HT": p_head * (1 - p_head),
"TH": (1 - p_head) * p_head,
"TT": (1 - p_head) * (1 - p_head),
}
def number_of_heads(outcome):
return outcome.count("H")
# Push probability mass through X(outcome) = number of heads.
pmf = {0: 0.0, 1: 0.0, 2: 0.0}
for outcome, prob in outcomes.items():
pmf[number_of_heads(outcome)] += prob
# Grouping changes where the mass lives, not the total amount of mass.
assert abs(sum(outcomes.values()) - 1.0) < 1e-12
assert abs(sum(pmf.values()) - 1.0) < 1e-12
mean = sum(x * prob for x, prob in pmf.items())
variance = sum((x - mean) ** 2 * prob for x, prob in pmf.items())
print("PMF:", {x: round(prob, 3) for x, prob in pmf.items()})
print("E[X]:", round(mean, 3))
print("Var(X):", round(variance, 3))
# Likelihood scores observed values under this distribution.
observed = np.array([2, 1, 1, 0, 2])
observed_masses = [pmf[int(x)] for x in observed]
log_likelihood = (
-math.inf
if any(prob == 0 for prob in observed_masses)
else sum(math.log(prob) for prob in observed_masses)
)
print("observed values:", observed.tolist())
print("log likelihood:", log_likelihood if math.isinf(log_likelihood) else round(log_likelihood, 3))
The code does not start with the binomial formula. It first assigns probability to raw outcomes, applies the random variable, and adds the mass that lands on the same value. The closed-form binomial PMF is the compact result of that aggregation.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Live Concept Demo
Explore Distributions
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Choose what to inspect in Distributions. This shared fallback is an observation guide, not evidence of learning.
Move the head-probability slider. The map from outcomes to X stays fixed, but the probability mass on outcomes changes, so the distribution of X changes.
Watch two things at once: the left side shows raw outcome probabilities, while the right side shows the aggregated probability mass function. The readout connects the distribution to expectation, variance, and a small i.i.d. observed-data log likelihood. At the endpoints, some observed values become impossible, so the log likelihood falls to negative infinity.
Copy-only prompts — each action copies a page-grounded prompt to your clipboard. Nothing is sent by this site.
Concept: Distributions
What is the smallest example that makes Distributions click without losing the math?
Object contextProbability
concept:probability/distributionsDistributions
What is the smallest example that makes Distributions click without losing the math?
Start with the prediction checkpoint, then compare the reveal to the mental model.
Take this moveStudy modes
Keep the object fixed; change the lens.Route back through the notebook
Carry the same object through intuition, math, code, and demo.
A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.
The next edge should feel earned: use the demo prediction here before following Maximum Likelihood.
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.Mechanism Storyboard
See the idea move before the page explains it
A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.

Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Distributions should make visible.
Visual Inquiry
Make the image answer a mathematical question
A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.
Which visible object should carry the first intuition?
Pick the cue that should make Distributions easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
What is the smallest example that makes Distributions click without losing the math?
concept:probability/distributionssources: deisenroth-2020-mml, goodfellow-2016-deep-learning
Open the closest source note before trusting the local explanation.
2 selected-object sources shown first; 2 references total.
Audit the claim boundary, then ask from the same selected object.
Grounds probability distributions, densities, expectations, and the notation used in ML models.
Mathematics for Machine Learning grounds random variables, distributions, densities, and expectations; Goodfellow et al. use the same probability vocabulary as the base language for proba...
This checks the probability-law framing and common PMF/density vocabulary, not measure-theoretic edge cases or every distribution family used in ML.
Grounds the probability and information-theory vocabulary reused by generative modeling pages.
Mathematics for Machine Learning grounds random variables, distributions, densities, and expectations; Goodfellow et al. use the same probability vocabulary as the base language for proba...
This checks the probability-law framing and common PMF/density vocabulary, not measure-theoretic edge cases or every distribution family used in ML.
Claim Review
A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.
What is the smallest example that makes Distributions click without losing the math?
concept:probability/distributionssources: deisenroth-2020-mml, goodfellow-2016-deep-learning
Treat every claim as provisional until source support and a local witness agree.
1 structured claim check on this concept.
Run the prediction or practice transfer before asking for a grounded review.
Publisher-side editorial review is not independent replication. Claims without it still need exact source-support review. 2 references and 3 local witnesses are available for inspection.
Mathematics for Machine Learning grounds random variables, distributions, densities, and expectations; Goodfellow et al. use the same probability vocabulary as the base language for probabilistic models and...
This checks the probability-law framing and common PMF/density vocabulary, not measure-theoretic edge cases or every distribution family used in ML.
Checked MML chapter 6.1-6.2 and Goodfellow chapter 3.3: MML defines a random variable as a map from outcomes to a target space, gives PX(S)=P(X in S)=P(X^-1(S)), and calls PX, or P composed with X^-1, the law/distribution of X. MML and Goodfellow both distinguish discrete PMFs from continuous densities/PDFs, with density probabilities obtained by integration over value sets.
Reviewer: codex+oracle; reviewed 2026-05-06Practice notebook
Use the idea, then test it somewhere new
A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.
What is the smallest example that makes Distributions click without losing the math?
concept:probability/distributionssources: deisenroth-2020-mml, goodfellow-2016-deep-learning
Use one state from Distributions to explain what changes, why it changes, and which assumption the explanation needs.
No learner move yet; no learning state is inferred.
Write first, use only the help you need, then try a new case without it.
Use one state from Distributions to explain what changes, why it changes, and which assumption the explanation needs.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Write an attempt before asking the companion.
0 of 3 progressive hints opened.
This draft and any AI response do not establish mastery; a later unassisted case can.
- ObjectConceptDistributions
- PredictBefore revealDistributions prediction
- WitnessCompare codeDistributions code witness 1
- RoomAsk groundedChecking local snapshot
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.Open the draft below to save one note and next action in this browser.
Distributions
What is the smallest example that makes Distributions click without losing the math?
These are fixed, deterministic perspectives derived from the selected object. They do not represent people, community contributions, or independent review.
Source ids deisenroth-2020-mml, goodfellow-2016-deep-learning must support the exact object, not just the surrounding topic.
Treat this as a mechanism object: connect the definition to one equation, code witness, or demo before broadening the discussion.
Ask the learner to perturb one representation, then check whether the same invariant survives in math, code, and demo.
The learner can state the mechanism in their own words
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays locally in this browser for concept:probability/distributions.
- Source ids to inspect: deisenroth-2020-mml, goodfellow-2016-deep-learning
- 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
- 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
I am working in Continuous Function's research reading room. Object: concept - Distributions Object key: concept:probability/distributions Context: Probability Anchor id: concept/concept-notebook/probability/distributions Open question: What is the smallest example that makes Distributions click without losing the math? Evidence to inspect: - Source ids to inspect: deisenroth-2020-mml, goodfellow-2016-deep-learning - 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, goodfellow-2016-deep-learning 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 "Distributions" feel predictable rather than familiar." | assumption: Source ids deisenroth-2020-mml, goodfellow-2016-deep-learning 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, goodfellow-2016-deep-learning" | 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 "Distributions" feel predictable rather than familiar. - Assumption to keep visible: Source ids deisenroth-2020-mml, goodfellow-2016-deep-learning 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/distributions
concept:probability/distributions