Exact values where possible; six decimal places otherwise.
STATEMENT
Show that the pathwise and score-function estimators of one gradient are
both unbiased, compute their variances, and follow them as the encoder’s
distribution narrows.
GIVEN
q=N(μ,s2), z=μ+sε with
ε∼N(0,1), and f(z)=z2. The target is
∂Eq[f(z)]/∂μ. The moments
E[ε2]=1, E[ε4]=3 and E[ε6]=15,
and odd moments vanish.
FIND
Both one-draw estimates, their means, their variances in general and at
μ=1, s=0.5, and their behaviour as s→0.
STRATEGY
Write each estimate as a polynomial in ε and take moments term
by term.
SOLUTION
The target. Eq[z2]=μ2+s2, so the derivative is 2μ.
Pathwise. By (I.13.6) the estimate is
gp=f′(z)=2(μ+sε). Its mean is 2μ and its
variance is
Vargp=4s2.Score function. By (I.13.7), with
∂logq/∂μ=(z−μ)/s2=ε/s,
gs=s(μ+sε)2ε.Expanding, (μ+sε)2ε=μ2ε+2μsε2+s2ε3, whose mean is
2μs. So Egs=2μ: unbiased. For the second moment,
(μ+sε)4ε2=μ4ε2+4μ3sε3+6μ2s2ε4+4μs3ε5+s4ε6,which averages to μ4+18μ2s2+15s4. Dividing by s2 and
subtracting the squared mean,
Vargs=s2μ4+18μ2s2+15s4−4μ2.The numbers. At μ=1, s=0.5 the pathwise variance is 1 and the
score-function variance is (1+4.5+0.9375)/0.25−4=21.75.
As s→0. The pathwise variance 4s2 goes to zero. The
score-function variance behaves like μ4/s2 and grows without bound:
| s | pathwise | score function |
|---|
| 0.5 | 1 | 21.75 |
| 0.1 | 0.04 | 114.15 |
| 0.01 | 0.0004 | 10,014 |
Answer
Both have mean 2μ. Variances 4s2 and
(μ4+18μ2s2+15s4)/s2−4μ2: at μ=1, s=0.5, 1 against
21.75. As s→0 the first vanishes and the second grows like
μ4/s2.
Check — sanity
At μ=0 the score-function variance is 15s2, finite and small, while
the pathwise variance is 4s2. The score function is worst when f is
large where q sits, because it multiplies f itself by
ε/s.
Where this breaks
The comparison depends on f. For an integrand that oscillates quickly,
such as sin(10z) in
I.13.X10, the order
reverses. A baseline subtracted from f can reduce the score function’s
variance a great deal without biasing it.
Variation
Subtract the baseline b=Eqf=μ2+s2 from f before multiplying by
ε/s. The estimate stays unbiased because
E[ε/s]=0. The estimate becomes
2με2+s(ε3−ε), with variance
8μ2+10s2. At μ=1, s=0.5 that is 10.5: half of 21.75, and
still ten times the pathwise 1.