Section 1: The dataset and the problem
The hidden distribution, the dataset I actually get, and why generative modeling starts there.
I am working through Mathematical Foundations of Generative AI, Prof. Prathosh AP’s public lectures. The playlist is the spine. These notes are my deep dive on each section: a visual when the picture is the point, a detour when a prerequisite is doing real work, and every formula read aloud with a plain-words line right after it.
Symbol cheat-sheet
| Symbol | Say it as | In plain words |
|---|---|---|
| ”capital D” | the dataset: the list of real examples I actually observe | |
| ”the set x-one through x-n” | a collection of data points | |
| ”n” | how many examples are in the dataset | |
| ”x-i” | the -th data point, e.g. one image as a list of numbers | |
| ”d” | dimensionality: how many numbers it takes to describe one data point | |
| ”in” | belongs to the set | |
| , | “the reals”, “R to the d” | ordinary numbers; lists of ordinary numbers |
| ”drawn from” | picked at random according to a distribution | |
| ”drawn i-i-d from” | each point is drawn independently from the exact same distribution | |
| ”independent of” | knowing one tells me nothing extra about the other | |
| , | “P-x”, “p-x of x” | the true, hidden data distribution and its density at |
| “P-theta” | the distribution of outputs produced by my model | |
| ”integral over x” | add up continuously over all possible values of | |
| “sum from i equals 1 to n” | add up one term for each of the items | |
| ”expected value of h of x, with x drawn from P-x” | the long-run average of over random draws from | |
| “approaches as n goes to infinity” | gets closer and closer as the sample size grows | |
| ”product over t” | multiply these terms together, one per step | |
| “probability of a given b” | how likely is once is already known |
Section 1: The dataset and the problem
Everything later in the playlist — GANs, VAEs, diffusion, transformers, state-space models, and preference tuning — starts from the same setup. I want this part solid before I touch a model.
The setup I am carrying:
Data (unknown), with , where is the dimensionality of the data. Example: is an image, , so . Goal: estimate and learn to sample from it.
1. Intuition first
Somewhere there is a hidden recipe — a probability distribution — that produced every cat photo, every English sentence, every speech clip. I never get the recipe. I get a pile of examples it produced. Generative modeling is using that pile to reconstruct the recipe well enough to cook up new examples from the same kitchen.
2. Real-world analogy
Think of a production web service whose request process I cannot inspect. All I have is an access log of 1,000 requests. I want a load-testing tool that produces synthetic traffic indistinguishable from real users: same mix of endpoints, same payload sizes, same timing.
| Load-testing analogy | Notation | In plain words |
|---|---|---|
| The real, unknown user behaviour | the hidden source of real data | |
| One logged request | one observed sample | |
| The fields in a log line | the coordinates of | the numbers that describe one sample |
| The access log | dataset | all samples I collected |
| The traffic generator | the generative model | the machine I am training |
| Synthetic requests it emits | samples from | new points generated by my model |
Two consequences follow. First, I do not need to write the user-behaviour formula down; I only need a generator whose output looks statistically indistinguishable from reality. That is why a GAN never writes down at all. Second, replaying the log is not the goal. I want brand-new requests, not copies.
3. Visual
A hidden 2-D distribution plays the role of . At first I only see the dots — the dataset. Reveal to see what is normally invisible, and drag to see how more data reveals the shape.
Each “Draw a new dataset” gives a different and the same green underneath. The dataset is random; the distribution is the fixed thing I am after. With the shape is a guess. With the two clumps are obvious.
4. The formula, decoded
Read aloud: “The dataset equals the set of points through , drawn independently and identically from , where each belongs to .”
In plain words: I have examples, each one is a list of numbers, and each one was picked independently from the same hidden source .
Piece by piece:
| Symbol | What it is | Type / shape | In plain words |
|---|---|---|---|
| the dataset | a set of vectors | the only thing I actually observe | |
| number of samples | integer | more data gives a clearer picture of | |
| one data point | vector in | an image, a sentence embedding, or a signal | |
| dimensionality | integer | how many numbers describe one point | |
| ”is drawn from” | relation | links data to its source | |
| iid | independent and identically distributed | assumption | makes learning from samples legitimate |
| true data distribution | distribution on | the hidden target, unknown |
Detour 1: Random variable and random vector
A random variable is a quantity whose value is decided by chance, like a die roll:
Read aloud: “capital belongs to the set one through six.”
In plain words: before I roll, the outcome is a random placeholder that will land on one of those six numbers.
A random vector is the same idea with several numbers at once, such as the height and weight of a randomly chosen person:
Read aloud: “capital belongs to R-two.”
In plain words: one random draw gives me a pair of ordinary numbers at the same time. Capital means the random thing in general; lowercase means one specific value that actually came out.
Back to the main thread. Each image in my dataset is one specific outcome of a random vector with coordinates.
Detour 2: Distribution and density
tells me how likely each possible value is. For a die it is a table: each face has probability . For continuous values, such as pixel intensities, it is a density — a heat map over space. High density means values land there often. In the chart above, the green shading is that density.
Two rules every density obeys:
Read aloud: “p-x of is at least zero, and the integral over all of of p-x of equals one.”
In plain words: likelihood is never negative anywhere, and if you add up the likelihood over every possible point in space, the total is 100% (which is 1).
Back to the main thread. I will write for both the distribution and its density, and be explicit whenever the distinction matters.
Detour 3: iid (independent and identically distributed)
Read aloud: ” is independent of for not equal to , and every is drawn from .”
In plain words: two rules hold at once:
- Identically distributed (): every point comes from the exact same source — every log line came from the same production user population, not half from production and half from a test script.
- Independent (): seeing tells me nothing extra about — the first roll of a die does not push the second roll around.
Back to the main thread. Why “unknown” is the whole problem: if I knew the formula for , I would sample from it directly and stop. Every model in the playlist is a different trick for working with through samples alone.
Why iid matters: the Law of Large Numbers. Because the samples are iid, I can replace an average over the unknown with a plain average over my dataset:
Read aloud: “one over times the sum from to of approaches the expected value of under as goes to infinity.”
In plain words: if you score every point in a large dataset and take the ordinary average, you get almost the exact same number you would get if you knew the true distribution . That single fact is the engine behind every training loss in the course.
Why is so large. A RGB image has three colour numbers per pixel:
Read aloud: “d equals 400 times 400 times 3, which is 480,000.”
In plain words: one single photo is a list of 480,000 numbers, or one point in . Real images occupy a tiny, thin region of that giant space; random lists of 480,000 numbers look like television static. This is the manifold hypothesis, and it comes back when naive GAN training fails.
Two jobs hiding in one goal
Given , “estimate and learn to sample from it” splits into two distinct jobs:
| Job | In plain words | Who emphasises it |
|---|---|---|
| Density estimation | Given a point , output a number saying how real or likely it is | Autoregressive models, VAEs (via a lower bound) |
| Sampling | Generate a brand-new point that looks like it came from | GANs (which never write a density down) and diffusion |
A GAN can generate crisp images and still be unable to tell me the probability of a photo I hand it.
5. Tiny worked example
Let and . Each point records (hours slept, coffees drunk) for a randomly surveyed person:
Read aloud: “the dataset consists of three points: , , and .”
In plain words: I surveyed three people; the first slept 7 hours and drank 1 coffee, the second slept 6 hours and drank 2 coffees, and the third slept 8 hours and drank 0 coffees.
Suppose I want the true average coffee intake under the unknown population . By the Law of Large Numbers, I estimate it with the sample average:
Read aloud: “the estimated expected number of coffees is one plus two plus zero, divided by three, which equals one.”
In plain words: averaging the coffee column across my three people gives 1 coffee per day.
The generative goal is bigger than one average: I want a machine that outputs plausible new pairs like — not copied from , and respecting the pattern that more sleep goes with less coffee.
6. Connect back
Every stretch of the lectures attacks “learn from ” with a different formula:
| Stretch | Model | Core formula | In plain words |
|---|---|---|---|
| Weeks 1–3 | GAN / divergence minimisation | push random noise through a network and shrink a divergence to | |
| Weeks 4–5 | VAE | explain each data point using a hidden latent code , and maximise a lower bound on log-likelihood | |
| Week 6 | WGAN | Wasserstein distance | same generator-critic game, but measure earth-mover distance so gradients do not flatten out |
| Weeks 7–8 | DDPM (diffusion) | slowly turn data into pure noise, then train a network to undo the noise step by step | |
| Week 10 | Autoregressive / Transformer | predict one token at a time given all earlier tokens | |
| Week 11 | SSM / Mamba | state-space recurrence | process sequences through a compact running state |
| Week 12 | RLHF / DPO | preference-tuned | nudge a trained generator toward outputs humans prefer |
Quick check (optional)
- If a dataset mixes 5,000 phone photos and 5,000 medical scans, which part of iid breaks, and why does that hurt?
- What is for a grayscale digit? For a RGB image?
- Once I have , do I know exactly? What changes as ?
Next: Section 2: The general principle of generative models.