Md. Asif Uddin
    Problem I.13.B04

    Two estimators of one gradient

    probability▲▲△

    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)q=\mathcal N(\mu,s^2), z=μ+sεz=\mu+s\varepsilon with ε∼N(0,1)\varepsilon\sim\mathcal N(0,1), and f(z)=z2f(z)=z^2. The target is ∂ Eq[f(z)]/∂μ\partial\,\E_q[f(z)]/\partial\mu. The moments E[ε2]=1\E[\varepsilon^2]=1, E[ε4]=3\E[\varepsilon^4]=3 and E[ε6]=15\E[\varepsilon^6]=15, and odd moments vanish.

    FIND

    Both one-draw estimates, their means, their variances in general and at μ=1\mu=1, s=0.5s=0.5, and their behaviour as s→0s\to0.

    STRATEGY

    Write each estimate as a polynomial in ε\varepsilon and take moments term by term.

    SOLUTION

    The target. Eq[z2]=μ2+s2\E_q[z^2]=\mu^2+s^2, so the derivative is 2μ2\mu.

    Pathwise. By (I.13.6) the estimate is gp=f′(z)=2(μ+sε)g_{\mathrm p}=f'(z)=2(\mu+s\varepsilon). Its mean is 2μ2\mu and its variance is

    Var⁡gp=4s2.\operatorname{Var}g_{\mathrm p}=4s^2.

    Score function. By (I.13.7), with ∂log⁡q/∂μ=(z−μ)/s2=ε/s\partial\log q/\partial\mu=(z-\mu)/s^2=\varepsilon/s,

    gs=(μ+sε)2 εs.g_{\mathrm s}=\frac{(\mu+s\varepsilon)^2\,\varepsilon}{s}.

    Expanding, (μ+sε)2ε=μ2ε+2μsε2+s2ε3(\mu+s\varepsilon)^2\varepsilon =\mu^2\varepsilon+2\mu s\varepsilon^2+s^2\varepsilon^3, whose mean is 2μs2\mu s. So Egs=2μ\E g_{\mathrm s}=2\mu: unbiased. For the second moment,

    (μ+sε)4ε2  =μ4ε2+4μ3sε3  +6μ2s2ε4+4μs3ε5  +s4ε6,\begin{aligned} &(\mu+s\varepsilon)^4\varepsilon^2\\ &\;=\mu^4\varepsilon^2+4\mu^3s\varepsilon^3\\ &\;\quad+6\mu^2s^2\varepsilon^4+4\mu s^3\varepsilon^5\\ &\;\quad+s^4\varepsilon^6, \end{aligned}

    which averages to μ4+18μ2s2+15s4\mu^4+18\mu^2s^2+15s^4. Dividing by s2s^2 and subtracting the squared mean,

    Var⁡gs  =μ4+18μ2s2+15s4s2  −4μ2.\begin{aligned} &\operatorname{Var}g_{\mathrm s}\\ &\;=\frac{\mu^4+18\mu^2s^2+15s^4}{s^2}\\ &\;\quad-4\mu^2. \end{aligned}

    The numbers. At μ=1\mu=1, s=0.5s=0.5 the pathwise variance is 11 and the score-function variance is (1+4.5+0.9375)/0.25−4=21.75(1+4.5+0.9375)/0.25-4=21.75.

    As s→0s\to0. The pathwise variance 4s24s^2 goes to zero. The score-function variance behaves like μ4/s2\mu^4/s^2 and grows without bound:

    sspathwisescore function
    0.50.51121.7521.75
    0.10.10.040.04114.15114.15
    0.010.010.00040.000410,01410{,}014

    Answer

    Both have mean 2μ2\mu. Variances 4s24s^2 and (μ4+18μ2s2+15s4)/s2−4μ2(\mu^4+18\mu^2s^2+15s^4)/s^2-4\mu^2: at μ=1\mu=1, s=0.5s=0.5, 11 against 21.7521.75. As s→0s\to0 the first vanishes and the second grows like μ4/s2\mu^4/s^2.

    Check — sanity

    At μ=0\mu=0 the score-function variance is 15s215s^2, finite and small, while the pathwise variance is 4s24s^2. The score function is worst when ff is large where qq sits, because it multiplies ff itself by ε/s\varepsilon/s.

    Where this breaks

    The comparison depends on ff. For an integrand that oscillates quickly, such as sin⁡(10z)\sin(10z) in I.13.X10, the order reverses. A baseline subtracted from ff can reduce the score function’s variance a great deal without biasing it.

    Variation

    Subtract the baseline b=Eqf=μ2+s2b=\E_q f=\mu^2+s^2 from ff before multiplying by ε/s\varepsilon/s. The estimate stays unbiased because E[ε/s]=0\E[\varepsilon/s]=0. The estimate becomes 2με2+s(ε3−ε)2\mu\varepsilon^2+s(\varepsilon^3-\varepsilon), with variance 8μ2+10s28\mu^2+10s^2. At μ=1\mu=1, s=0.5s=0.5 that is 10.510.5: half of 21.7521.75, and still ten times the pathwise 11.

    Draws on