Why the square roots?
Alpha-bar is 0.36, yet the formula multiplies the signal by √0.36 = 0.6. Both are right, because they measure different things. In level 10 you measured how spread out numbers are with the std. Squaring the std gives the variance, and variance is what alpha-bar counts: 36% of the signal’s variance is left. Multiplying a number by 0.6 multiplies its variance by 0.6² = 0.36.
The noise gets the rest. Its weight is √(1 − 0.36) = √0.64 = 0.8, so its variance is 0.8² = 0.64.
That sum is the reason for the square roots. The two weights, squared, always add up to 1, at every step. So if the clean data has variance 1, the noisy data has variance 1 at every step too: the cloud only changes from “spiral” into “noise”, and never grows or shrinks. Real models scale their data to variance 1 for this reason. Our spiral has a variance of about 0.6, so its cloud grows a little as it becomes noise with variance 1.
Now compute it for one point. Take x0 = [1, 2] and the noise eps = [0.5, -1].
At t = 3, √0.36 = 0.6 and √(1 − 0.36) = 0.8. After you answer, switch the lab to Hand example · 3 steps and drag to t = 3 to watch the point move.
I got stuck here Why jump straight to step t? Don’t you have to add the noise one step at a time?
You can add it one step at a time and get the same kind of result. Adding two independent normal noises gives one bigger normal noise, so all t steps combine into one formula. That shortcut matters for training: to make a training example at step 37, you don’t have to run 37 steps. Compute alpha-bar once and jump there.
Write the shortcut yourself. It works on one point or on a whole array of points at once.
add_noise. ab is alpha-bar. It should work for one point or for an array of points.Enter keeps the indent · Tab indents · Esc then Tab leaves the editor · ⌘/Ctrl + Enter runs
Now put both parts together: start from the list of betas and return the noisy point at step t. Three pieces of NumPy do it:
betas[:t]takes the first t betas (positions 0 to t − 1), so step t uses steps 1 to t.1 - betas[:t]turns them into the α values, what each step keeps.np.prodmultiplies all the numbers of an array:np.prod(np.array([0.9, 0.8, 0.5]))is 0.36.
noisy_at: from the clean point x0, the noise eps, the list of betas and a step t (counting from 1), compute alpha-bar for step t, then return the noisy point xₜ.Enter keeps the indent · Tab indents · Esc then Tab leaves the editor · ⌘/Ctrl + Enter runs