Macalinao StudioLearnAll enriched lessons ↗
College path · 7 sectionsSwitch to high school ↗

College / LONGER LESSON f-diff-math

Diffusion math: from one transition to a sampler

Distinguish transition and marginal noise, derive a reconstruction, and inspect reverse uncertainty.

Preparation: Squares and random noise; Gaussian distributions for college.

Plan 20–35 minutes with the activities; this is a study estimate, not a timed requirement. Both paths have complete narration. Your notes and progress are kept separately for each level.

Section 01 / 07

One small corruption step

College path. Distinguish transition and marginal noise, derive a reconstruction, and inspect reverse uncertainty.

Preparation: Squares and random noise; Gaussian distributions for college. Work through one section at a time. Predict the experiment result before changing its controls, then explain what the example leaves out.

The forward transition is q(x_t|x_{t−1})=N(√α_t x_{t−1},β_t I), with α_t=1−β_t. Independent standard Gaussian noise produces the equivalent sample equation. Beta is a variance contribution, so its amplitude coefficient is √β_t. The forward process is prescribed rather than learned in the basic DDPM construction. A valid schedule keeps variance parameters in their intended range.

Worked step 1. Let beta=0.1 and alpha=0.9.

Worked step 2. Signal amplitude coefficient is √0.9≈0.9487.

Worked step 3. Noise amplitude coefficient is √0.1≈0.3162.

x_t=√α_t x_(t−1)+√β_t ε_t

Multiply the previous sample by square root alpha and add fresh standard noise scaled by square root beta.

Try it yourself. Why not multiply the new noise by beta directly?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. Because beta specifies variance. Standard deviation, the amplitude multiplier, is its square root.

Section 02 / 07

Combine many steps into a marginal

Define ᾱ_t as the product of α_s from one through t. Gaussian composition yields q(x_t|x_0)=N(√ᾱ_t x_0,(1−ᾱ_t)I). The aggregated epsilon in this marginal is standard normal, formed from the independent transition noises with appropriate coefficients. Equality of marginal distributions does not imply that separately sampled paths are identical. Distinguish α_t, one-step retention, from ᾱ_t, cumulative retention.

Worked step 1. Two steps with alpha 0.9 give cumulative alpha 0.81.

Worked step 2. The original-signal amplitude is √0.81=0.9.

Worked step 3. The combined noise amplitude is √0.19≈0.4359.

ᾱ_t=∏ₛ₌₁ᵗ α_s; x_t=√ᾱ_t x₀+√(1−ᾱ_t)ε

Multiply all retention factors to obtain cumulative alpha, then use its square root in the direct marginal formula.

Try it yourself. Is cumulative alpha after two steps equal to the last step’s alpha?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. No. It is the product across steps. Using only the last alpha understates accumulated corruption.

Section 03 / 07

Predict noise from the corrupted input

An epsilon-prediction objective compares εθ(x_t,t) with sampled ε, often using a simplified mean squared error. Weighting across time and parameterization affect the objective; epsilon, x_0 and velocity prediction are related but not interchangeable labels. Time conditioning identifies the corruption level. The model must infer a distributional denoising direction from noisy data, not recover a supplied random seed.

Worked step 1. Sample clean x₀ and a time t.

Worked step 2. Draw epsilon and construct x_t with the forward marginal.

Worked step 3. Compare the network’s epsilon prediction with the sampled epsilon.

L_simple=E[||ε−εθ(x_t,t)||²]

The simplified loss averages squared differences between sampled noise and predicted noise.

Try it yourself. Does the denoiser receive the exact sampled noise as an input?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. No. That noise is the training target. Supplying it would bypass the prediction problem.

Section 04 / 07

Reconstruct and see error amplification

The estimate x̂_0=(x_t−√(1−ᾱ_t)ε̂)/√ᾱ_t has error −√((1−ᾱ_t)/ᾱ_t)δ when ε̂=ε+δ. Signal-to-noise ratio is ᾱ_t/(1−ᾱ_t) under standardized signal/noise assumptions. The error amplification is therefore inverse square root SNR. This algebra describes a parameterization relationship; a practical sampler can use additional clipping, variance choices or alternate prediction targets.

Worked step 1. At cumulative alpha 0.64, noise-error amplification is 0.6/0.8=0.75.

Worked step 2. A noise error of 0.1 causes clean-estimate error −0.075.

Worked step 3. At cumulative alpha 0.01, the amplification is about 9.95.

x̂₀−x₀=−√((1−ᾱ_t)/ᾱ_t)δ

Clean-estimate error is minus the noise-prediction error times the square root of noise variance divided by signal variance.

Try it yourself. Why is the same noise-prediction error more damaging when little signal remains?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. The reconstruction divides by a smaller signal coefficient, amplifying the error.

Section 05 / 07

Reverse uncertainty is not arbitrary

The forward posterior q(x_{t−1}|x_t,x_0) is Gaussian with variance β̃_t=β_t(1−ᾱ_{t−1})/(1−ᾱ_t). Its mean depends on both x_t and x_0. Generation instead uses a learned reverse model conditioned on x_t, commonly through a noise prediction. Fixed, learned or alternative sampler variances must be specified. The posterior variance formula is not automatically the variance used by every diffusion implementation.

Worked step 1. Use beta=0.1 for two steps: previous cumulative alpha=0.9 and current=0.81.

Worked step 2. Posterior variance is 0.1×0.1/0.19≈0.05263.

Worked step 3. This differs from the forward-step variance 0.1.

β̃_t=β_t(1−ᾱ_(t−1))/(1−ᾱ_t)

Posterior variance is beta times one minus previous cumulative alpha, divided by one minus current cumulative alpha.

Try it yourself. Why can generation not directly use the true forward-posterior mean involving x₀?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. The clean sample is unknown during generation. The learned reverse model must supply the missing information.

Section 06 / 07

A schedule and a sampler are separate choices

Distinguish training-time schedule, prediction parameterization and inference solver. Changing the number or spacing of inference steps is not the same as retraining the forward process. Solver order, stochasticity, guidance and variance choices interact with the trained model. Validate marginal identities and posterior coefficients with small numerical fixtures, then evaluate actual sample quality and compute on a documented model rather than extrapolating from one-dimensional algebra.

Worked step 1. Check that cumulative alpha decreases under positive beta steps.

Worked step 2. Check the oracle reconstruction with zero prediction error.

Worked step 3. Then vary error and time to expose sensitivity without claiming image-generation performance.

Try it yourself. Does a shorter list of reverse steps necessarily sample the same distribution?

Pause the recording and write your reasoning before continuing. The worked solution follows.

Reveal worked solution

Worked solution. No. That depends on the method and assumptions. Speed, approximation error and output quality require evaluation.

Section 07 / 07

Mastery and transfer

Bring the pieces together. First answer the checkpoint without the worked solutions. Then explain the mechanism in your own words, using one numerical example from this lesson.

If ε̂=ε+δ, clean reconstruction error scales as… Option 1: −√((1−ᾱ)/ᾱ)δ. Option 2: Always zero. Option 3: ᾱδ only.

Pause here and choose an answer before continuing. The checkpoint explanation follows.

Reveal worked solution

The correct choice is option 1: −√((1−ᾱ)/ᾱ)δ. Rearranging the forward marginal exposes the inverse-signal amplification.

Transfer task. Change one assumption in the worked example. State your prediction, calculate or test it in Workbench, then explain whether the result supports your prediction.

Reveal worked solution

Self-check rubric. Name the changed assumption, keep the other inputs fixed, show at least one intermediate calculation, and distinguish what the toy example guarantees from what would require a trained model or a real measurement.

Sources and scope

Original worked examples and teaching text, grounded in these primary references. Numerical fixtures explain mechanisms; model quality and hardware performance require separate measurements. Both levels share key examples, with different explanations and checkpoints.

Reset this college path?

This removes only this path’s notes, progress and experiments from this browser.