In a diffusion model, the diffusion or forward process maps a data example through a series of intermediate variables .
- Note that this is opposite nomenclature to normalizing flows, where the inverse mapping moves from the data to the latent variable.
The mapping is done according to
where is drawn from a standard normal distribution.
- The first term attenuates the data plus any noise added so far
- The second term adds more noise
- The hyperparameters determine how quickly the noise is blended and are collectively known as the noise schedule.

The forward process can be equivalently written as:
This is a Markov Chain because the probability is determined entirely by the value of the immediately preceding valuable . With sufficient steps , all traces of the original data are removed, and becomes a standard normal distribution.
The joint distribution of all latent variables given input is:
Diffusion kernel
To train the decoder to invert this process, we use multiple samples at time for the same example . However, generating these sequentially using the above equations step-by-step is time-consuming when is large. Fortunately, there is a closed-form expression for , which allows us to directly draw samples given initial datapoint without computing the intermediate variables . This is known as the diffusion kernel.

To derive an expression for , consider the first two steps of the forward process:
Substituting the first equation into the second, we get:
The last two terms are independent samples from mean-zero normal distributions with variances and , respectively. The mean of this sum is zero, and its variance is the sum of the component variances (see problem 18.2), so:
where is also a sample from a standard normal distribution.
If we continue this process by substituting this equation into the expression for and so on, we can show that:
We can equivalently write this in probabilistic form:
For any starting data point , variable is normally distributed with a known mean and variance. Consequently, if we don’t care about the history of the evolution through the intermediate variables , it is easy to generate samples from .
Marginal distributions
The marginal distribution is the probability of observing a value of given the distribution of possible starting points and the possible diffusion paths for each starting point.

It can be computed by considering the joint distribution and marginalizing over all the variables except :
where was defined above as the joint distribution of all latent variables.
However, since we now have an expression for the diffusion kernel that skips the intervening variables, we can equivalently write:
Hence, if we repeatedly sample from the data distribution and superimpose the diffusion kernel on each sample, the result is the marginal distribution . However, the marginal distribution cannot be written in closed form because we don’t know the original data distribution .
Conditional distribution
We defined the conditional probability in the forward process. To reverse this process, we apply Bayes’ Rule:
This is intractable since we cannot compute the marginal distribution .
For simple 1D examples, it’s possible to evaluate numerically. In general, their form is complex, but in many cases, they are well-approximated by a normal distribution. This is important because when we build the decoder, we will approximate the reverse process using a normal distribution.

Conditional diffusion distribution
There is one final distribution related to the encoder to consider. We noted above that we could not find the conditional distribution because we do not know the marginal distribution . However, if we know the starting variable , then we do know the distribution at the time before. This is just the diffusion kernel, and it is normally distributed.
Hence, it is possible to compute the conditional diffusion distribution in closed form. This distribution is used to train the decoder. It is the distribution over when we know the current latent variable and the training data example (which we of course know).

To compute an expression for we start with Bayes’ rule:
- Between the first two lines, we have used the fact that because the diffusion process is Markov, and all the information about is captured by .
- Between lines 3 and 4, we use the Gaussian change of variables identity: to rewrite the first distribution in terms of .
We then use a second Gaussian identity:
to combine the two normal distributions in , which gives:
Note that the constants of proportionality in the equations above must cancel out since the final result is already a correctly normalized probability distribution.