Grounds probability distributions, densities, expectations, and the notation used in ML models.
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.
Intuition
The idea in plain words, before the symbols.
The raw outcome might be , , , or , but your model only records number of heads. So what is the probability of ?
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: 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 is the number of heads in two coin flips, both and become . The probability of 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.
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.
Let be a probability space. Let be the measurable space of values, and let
be a measurable random variable. The distribution, or law, of is the probability measure on values:
Here is a measurable set of values. Equivalently, .
This is called the pushforward of through . It says: start with probability on raw outcomes, apply the measurement , and add up the probability that lands inside each value-set .
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 :
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 .
When 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, has a density 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 , because they depend on the units of . 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 and random variable number of heads. Then has a binomial distribution:
Its expectation and variance are
In machine learning, a parametric distribution family writes this mass or density as . If observed values are treated as independent draws from the distribution, the log likelihood is
For discrete data, is a probability mass. For continuous data, is a density value, so likelihood scores density at the observations; it is not the probability of observing those exact points.
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 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.
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 Distributions
Observation guide
Optional and ungraded. Opening a guide saves nothing.
Choose what to inspect in Distributions, then open its guide.
Move the head-probability slider. The map from outcomes to stays fixed, but the probability mass on outcomes changes, so the distribution of changes. Before the grouped distribution appears, predict which value of collects the most probability mass.
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.
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: Distributions
What is the smallest example of Distributions you can work through by hand, and what does it show?
DetailsProbability
Reference id
concept:probability/distributionsAfter 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
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.
Choose what you expect to see in this section of Distributions.
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
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 part of the picture should you look at first?
Pick the part of the picture you expect to explain Distributions.
Sources
References for this page
A reference shows where an idea comes from; it does not vouch for every step on this page.Grounds the probability and information-theory vocabulary reused by generative modeling pages.
Springer; in English as Foundations of the Theory of Probability (Chelsea, 1950). Defines the distribution of a random variable as the probability it induces on values.
Chapman & Hall/CRC. Chapter 3 builds PMFs and CDFs, including the binomial, by grouping outcomes; Chapter 5 covers densities.
What each claim rests on1 claim, each with its sources, where it appears on this page, and its caveats.
Claims and sources
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 checks were made by this site, not by an independent reviewer.
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.
Explain it without the pageWrite your own explanation before asking for feedback. Your draft and any hints stay while this page is open.
Practice · Distributions
Try the idea in your own words
A distribution is the law of a random variable: it says how probability mass or density lands on the values the variable can take.
Concept · Selected for practice
Distributions
What it rests on: Sources: Mathematics for Machine Learning; Deep Learning; Grundbegriffe der Wahrscheinlichkeitsrechnung
Context and links
Probability
Explain the mechanism
For Distributions: What is the smallest example of Distributions 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(outcomes.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.
Distributions
What is the smallest example of Distributions 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 4 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 4 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/distributions
concept:probability/distributions