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) = \phi(z)$. From $\phi(z)$, one can generate a scale/location family of probability densities by scaling and shifting $\phi(z)$:

$$ \Pr\left( x ; \mu, \sigma \right) = \frac 1 \sigma \phi \left( \frac {x - \mu}{\sigma} \right) $$

The most familiar example of such a family is the univariate Gaussian distribution, when $\phi(z) = [ 2\pi]^{-1/2}\exp\left(-\tfrac 1 2 z^2\right)$. Now, consider the expectation of a function of $\langle f(x) \rangle$ with respect to $\Pr\left( x \right)$.

$$ \langle f(x) \rangle = \int_{\mathbb R} f(x) \Pr(x) dx = \int_{\mathbb R} f(x) \frac 1 \sigma \phi\left(\frac{x-\mu}{\sigma}\right) dx $$

What are the derivatives of $\langle f(x) \rangle$ with respect to $\mu$ and $\sigma^2$? The answers are:

\begin{equation}\begin{aligned} \partial_\mu \langle f(x) \rangle &= \langle f'(x) \rangle \\ \partial_{\sigma^2} \langle f(x)\rangle &= \tfrac1{2\sigma^2} \left<(x-\mu) f'(x)\right>_x \end{aligned}\end{equation}