Numerical approximation of expected value of sigmoid function w.r.t Gaussian distribution

89 Views Asked by At

I'm reading the book computer vision:models, learning and inference, in formula (9.19), it proposes to numerically approximate an integration $\int f(x)g_{\mu,\sigma}(x)dx \approx f(\mu/\sqrt{1+\pi\sigma^2/8}$), where $g_{\mu,\sigma}(x)$ is the density function of a (univariate) Gaussian distribution with mean $\mu$ and standard deviation $\sigma$, and particularly in the book the $f(x)=1/(1+\exp(-x))$ (the sigmoid function).

I just wonder why this is reasonable? There's no hint in the book and I have no idea what's the keyword for the formula.

1

There are 1 best solutions below

3
On BEST ANSWER

Piecing together discussions from here and here.

Let $f(x) = \frac{1}{1+e^{-x}}$. Let $\Phi(x)$ and $\phi(x)$ be the CDF and PDF of the standard normal distribution respectively.

Lemma 1: $f(x) \approx \Phi(\lambda x)$ where $\lambda=\sqrt{\pi/8}$.

Lemma 2: $\int_{-\infty}^\infty \Phi\left(\frac{x-a}{b}\right) \phi(x) \, dx = \Phi\left(\frac{-a}{\sqrt{b^2+1}}\right)$.

\begin{align} \int_{-\infty}^\infty f(x) g_{\mu, \sigma}(x) \, dx &= \int_{-\infty}^\infty f(\sigma u + \mu) \phi(u) \, du & \text{change of variables} \\ &\approx \int_{-\infty}^\infty \Phi(\lambda(\sigma u + \mu)) \phi(u) \, du & \text{Lemma 1} \\ &= \int_{-\infty}^\infty \Phi\left(\frac{u + \mu /\sigma}{1/(\sigma \lambda)}\right) \phi(u) \, du \\ &= \Phi\left(\frac{\mu/\sigma}{\sqrt{(\sigma \lambda)^{-2} + 1}}\right) & \text{Lemma 2} \\ &= \Phi\left(\frac{\mu}{\sqrt{\lambda^{-2} + \sigma^2}}\right) \tag{$*$} \\ &\approx f\left(\frac{\mu}{\sqrt{1 + \sigma^2 \lambda^2}}\right). & \text{Lemma 1 again} \end{align}

As a sanity check, ($*$) matches korkinof's answer. Your book takes one more step to approximate $\Phi$ by $f$.