Full DDPM Ancestral Step
Problem Statement
Implement one complete DDPM ancestral sampling step: the eps-parameterized mean plus the injected posterior noise sigma_t * z.
Background
The reverse mean from a noise prediction is
Then a sample is drawn as x_{t-1} = mu + sigma_t * z where z is supplied and sigma_t = sqrt(beta_tilde_t) with the posterior variance beta_tilde_t = (1 - alpha_bar_prev)/(1 - alpha_bar_t) * beta_t. At the final step (alpha_bar_prev == 1) no noise is added.
Your Task
Implement:
def ddpm_step(x_t, eps, z, beta_t, alpha_bar_t, alpha_bar_prev):
Return x_{t-1} as a list rounded to 4 decimals. If alpha_bar_prev == 1.0, return the mean only.
Input Format
- x_t, eps, z: lists of length D.
- beta_t, alpha_bar_t, alpha_bar_prev (float).
Output Format
- A list of D floats rounded to 4 decimals.
Sample
print(ddpm_step([1.0, 1.0], [0.0, 0.0], [1.0, -1.0], 0.2, 0.5, 0.64))
Output:
[1.4975, 0.7386]
Example
print(ddpm_step([1.0, 1.0], [0.0, 0.0], [1.0, -1.0], 0.2, 0.5, 0.64))
[1.4975, 0.7386]
eps=0 so mean = x_t/sqrt(0.8) = [1.1180,1.1180]. sigma = sqrt(0.36/0.50.2) = sqrt(0.144) = 0.3795. x = mean + 0.3795[1,-1] = [1.4975, 0.7386].
Constraints
len(x_t) == len(eps) == len(z); schedule values in(0, 1).sigma_t = sqrt((1-alpha_bar_prev)/(1-alpha_bar_t)*beta_t).- No noise when
alpha_bar_prev == 1.0; round to 4 decimals; avoid-0.0.