Wednesday, May 16, 2012

Note: Differentiating expectations of a function of a random variable with respect to location and scale parameters

Consider a real-valued random variable with a known probability distribution Pr(z)=ϕ(z). From ϕ(z), one can generate a scale/location family of probability densities by scaling and shifting ϕ(z):

Pr(x;μ,σ)=1σϕ(xμσ)

The most familiar example of such a family is the univariate Gaussian distribution, when ϕ(z)=[2π]1/2exp(12z2). Now, consider the expectation of a function of f(x) with respect to Pr(x).

f(x)=Rf(x)Pr(x)dx=Rf(x)1σϕ(xμσ)dx

What are the derivatives of f(x) with respect to μ and σ2? The answers are:

(1)μf(x)=f(x)σ2f(x)=12σ2(xμ)f(x)x

This question often appears in the special case that x is normally distributed; You'll find derivations elsewhere online given in terms of the cumulative distribution function of the standard normal distribution.

This note outlines a derivation for any scale/location family using elementary calculus. These derivatives can be obtained by considering how perturbing μ or σ shifts and/or scales the probability density.

For the mean, consider the definition of the derivative:

(2)ddμf(x)=limϵ01ϵ{Rf(x)1σϕ(xϵμσ)dxRf(x)1σϕ(xμσ)dx}=limϵ01ϵ{Rf(x)1σϕ(xϵμσ)dxf(x)}

Let y=xϵ. Then perform a change of variables (dy=dx and x=y+ϵ):

(3)ddμf(x)=limϵ01ϵ{Rf(y+ϵ)1σϕ(yμσ)dyf(x)}=limϵ01ϵ{f(x+ϵ)f(x)}=limϵ01ϵ{f(x)+ϵf(x)f(x)}=f(x)

For the variance, consider the derivative in σ:

(4)ddσf(x)=limϵ01ϵ{Rf(x)1σ+ϵϕ(xμσ+ϵ)dxf(x)}

Let y=σσ+ϵ(xμ)+μ. This gives the change of variables (5)dz=σ+ϵσdyx=σ+ϵϵ(yμ)+μ=y+ϵσ(yμ)

Substituting, and simplifying:

(6)ddσf(x)=limϵ01ϵ{Rf(y+ϵσ(yμ))1σ+ϵϕ(yμσ+ϵ)σ+ϵσdyf(x)}=limϵ01ϵ{Rf(y+ϵσ(yμ))1σϕ(yμσ+ϵ)dyf(x)}=limϵ01ϵ{f(y+ϵσ(yμ))f(x)}=limϵ01ϵf(x)ϵσ(xμ)=1σf(x)(xμ)

To get the derivative in terms of the variance σ2, apply the chain rule

(7)ddσ2f(x)=dσdσ2ddσf(x)=12σ2f(x)(xμ)

No comments:

Post a Comment