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

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.

published · difficulty 2/5 · 15 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.

The raw outcome might be HHHHHH, HTHTHT, THTHTH, or TTTTTT, but your model only records X=X=X= number of heads. So what is the probability of X=1X=1X=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: XXX 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 XXX is the number of heads in two coin flips, both HTHTHT and THTHTH become X=1X=1X=1. The probability of X=1X=1X=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.

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.

Let (Ω,F,P)(\Omega,\mathcal F,P)(Ω,F,P) be a probability space. Let (S,S)(S,\mathcal S)(S,S) be the measurable space of values, and let

X:(Ω,F)(S,S)X:(\Omega,\mathcal F)\to(S,\mathcal S)X:(Ω,F)(S,S)

be a measurable random variable. The distribution, or law, of XXX is the probability measure PXP_XPX on values:

PX(A)=P(XA)=P({ωΩ:X(ω)A}).P_X(A)=P(X\in A)=P(\{\omega\in\Omega:X(\omega)\in A\}).PX(A)=P(XA)=P({ωΩ:X(ω)A}).

Here ASA\in\mathcal SAS is a measurable set of values. Equivalently, PX(A)=P(X1(A))P_X(A)=P(X^{-1}(A))PX(A)=P(X1(A)).

This is called the pushforward of PPP through XXX. It says: start with probability on raw outcomes, apply the measurement XXX, and add up the probability that lands inside each value-set AAA.

For a discrete random variable, the probability mass function is

pX(x)=P(X=x).p_X(x)=P(X=x).pX(x)=P(X=x).

If the raw sample space is finite, this is just the mass of every outcome that maps to xxx:

pX(x)=ω:X(ω)=xP(ω).p_X(x)=\sum_{\omega:X(\omega)=x}P(\omega).pX(x)=ω:X(ω)=xP(ω).

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\sum_x p_X(x)=1xpX(x)=1.

When XXX is real-valued, the cumulative distribution function is

FX(t)=P(Xt).F_X(t)=P(X\le t).FX(t)=P(Xt).

It accumulates the mass up to a threshold. For many real-valued distributions used in machine learning, PXP_XPX has a density fXf_XfX and interval probabilities are computed by integration:

P(aXb)=abfX(x)dx.P(a\le X\le b)=\int_a^b f_X(x)\,dx.P(aXb)=abfX(x)dx.

A density value is not itself a probability; only area under the density over a region is probability. Density values can be greater than 111, because they depend on the units of xxx. 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 ppp and random variable X=X=X= number of heads. Then XXX has a binomial distribution:

P(X=k)=(2k)pk(1p)2k,k{0,1,2}.P(X=k)=\binom{2}{k}p^k(1-p)^{2-k},\qquad k\in\{0,1,2\}.P(X=k)=(k2)pk(1p)2k,k{0,1,2}.

Its expectation and variance are

E[X]=2p,Var(X)=2p(1p).\mathbb E[X]=2p,\qquad \operatorname{Var}(X)=2p(1-p).E[X]=2p,Var(X)=2p(1p).

In machine learning, a parametric distribution family writes this mass or density as pθ(x)p_\theta(x)pθ(x). If observed values x(1),,x(n)x^{(1)},\dots,x^{(n)}x(1),,x(n) are treated as independent draws from the distribution, the log likelihood is

(θ)=i=1nlogpθ(x(i)).\ell(\theta)=\sum_{i=1}^n \log p_\theta(x^{(i)}).(θ)=i=1nlogpθ(x(i)).

For discrete data, pθ(x)p_\theta(x)pθ(x) is a probability mass. For continuous data, pθ(x)p_\theta(x)pθ(x) is a density value, so likelihood scores density at the observations; it is not the probability of observing those exact points.

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 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.

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 Distributions

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

difficulty 2/5undergraduatecode-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: Maximum Likelihood

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

Loading interactive demo...

Move the head-probability slider. The map from outcomes to XXX stays fixed, but the probability mass on outcomes changes, so the distribution of XXX 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.

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: Distributions

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

BeforeRandom VariablesNow4/4 sections readyTryManipulate one control and predict the visible change.NextMaximum Likelihood
Object contextProbability
ConceptLearner lens

Distributions

What is the smallest example that makes Distributions 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 inRandom Variables

Bring the mental model from Random Variables; this page will reuse it instead of restarting from zero.

Work hereDistributions

A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.

Carry outMaximum Likelihood

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.
ConceptDistributionsProbability

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.

Demo notes open01 / Intuition
Editorial probability illustration of probability mass pushed through a random variable into PMF bars and density curves.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

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.

4/4 stages readyDemo notes connected
Prediction

Which visible object should carry the first intuition?

Commit first

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.

Object - ConceptDistributionsQuestion

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

concept:probability/distributions
Boundary

sources: deisenroth-2020-mml, goodfellow-2016-deep-learning

Check

Open the closest source note before trusting the local explanation.

Evidence

2 selected-object sources shown first; 2 references 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 distributions, densities, expectations, and the notation used in ML models.

Used here as

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...

Caveat

This checks the probability-law framing and common PMF/density vocabulary, not measure-theoretic edge cases or every distribution family used in ML.

Open source
selected object source · book · 2016Deep LearningGoodfellow, Bengio, and Courville
Located CF editorial boundary

Grounds the probability and information-theory vocabulary reused by generative modeling pages.

Used here as

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...

Caveat

This checks the probability-law framing and common PMF/density vocabulary, not measure-theoretic edge cases or every distribution family used in ML.

Open source

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.

Object - ConceptDistributionsQuestion

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

concept:probability/distributions
Boundary

sources: deisenroth-2020-mml, goodfellow-2016-deep-learning

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. 2 references and 3 local witnesses are available for inspection.

A distribution is the probability law induced by a random variable: it pushes probability from raw outcomes onto measurable value sets, with PMFs and densities as common representations.
Used here as

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...

Local witness
Equation 1
X:(Ω,F)(S,S)X:(\Omega,\mathcal F)\to(S,\mathcal S)
Equation 2
PX(A)=P(XA)=P({ωΩ:X(ω)A}).P_X(A)=P(X\in A)=P(\{\omega\in\Omega:X(\omega)\in A\}).
Caveat

This checks the probability-law framing and common PMF/density vocabulary, not measure-theoretic edge cases or every distribution family used in ML.

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.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-06

Practice 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.

AttemptNo learning claim inferred
Object - ConceptDistributionsQuestion

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

concept:probability/distributions
Boundary

sources: deisenroth-2020-mml, goodfellow-2016-deep-learning

Check

Use one state from Distributions 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 Distributions 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, goodfellow-2016-deep-learning
  1. ObjectConceptDistributions
  2. PredictBefore revealDistributions prediction
  3. WitnessCompare codeDistributions code witness 1
  4. RoomAsk groundedChecking local snapshot
ConceptDistributionsProbability

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

Distributions

Anchored question

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

Source boundaryInspect source ids: deisenroth-2020-mml, goodfellow-2016-deep-learningStable 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 "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.

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, goodfellow-2016-deep-learning
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/distributions.

No local draft saved.
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
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 - 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