Why the distribution is unchanged. A linear transform of a normal is normal. Scaling ε by σ gives mean 0 and variance σ²; adding μ shifts the mean to μ and leaves the variance alone. So μ + σ·ε has exactly the distribution of a direct draw.
Why the gradient exists. With ε held fixed, z is ordinary arithmetic. The derivative of the loss L with respect to μ is the loss gradient at z times 1; with respect to σ it is the loss gradient times ε.
numeric check — μ = 2, σ = 0.5, one draw ε = 1.2:
z = μ + σ·ε = 2 + 0.5·1.2 = 2.6
loss L = z² = 6.76 (a stand-in for the decoder loss)
dL/dz = 2z = 5.2
dL/dμ = dL/dz · ∂z/∂μ = 5.2 · 1 = 5.2
dL/dσ = dL/dz · ∂z/∂σ = 5.2 · 1.2 = 6.24
finite-difference check on σ, same ε, h = 0.001:
z(σ+h) = 2 + 0.501·1.2 = 2.6012
L(σ+h) = 6.766241
(6.766241 − 6.76) / 0.001 = 6.241 ✓ matches 6.24
Discrete choices need a different trick. For a categorical draw, the same idea is Gumbel-Softmax: add Gumbel noise g = −ln(−ln u) to the log-probabilities and take a softmax with temperature τ instead of a hard argmax. Numeric check with probabilities [0.5, 0.3, 0.2] and uniforms [0.9, 0.5, 0.1]:
g = [2.2504, 0.3665, −0.8340]
log p + g = [1.5572, −0.8375, −2.4435]
τ = 0.5 → softmax ≈ [0.991, 0.008, 0.0003] almost a one-hot sample
τ = 1.0 → softmax ≈ [0.901, 0.082, 0.017] softer, still differentiable
as τ → 0 the output approaches a hard categorical sample;
as τ → ∞ it approaches uniform. Gradients flow through the softmax.
Two related ideas round out the toolbox. Stratified sampling splits the space into equal strata and takes one draw per stratum, which can only lower the variance of a Monte Carlo estimate. And every diffusion step is a reparameterized Gaussian sample: x[t−1] = mean + σ_t·z with z ~ N(0, I) — the same move, repeated a thousand times.