The expectation of binary logistics regression with respect to Gaussian distribution I am trying to compute the expectation of $g(s,x)=s \ln \sigma(x)+(1-s)\ln(1-\sigma(x))$ with respect to the normal distribution $\mathcal{N}(x;m,v)$, where we have $\sigma(x)=\frac{1}{1+e^{-x}}$. If we define $$\langle g(s,x)\rangle_q=\int\mathcal{N}(x;m,v)g(s,x)\mathrm{d}x$$
I would like to re-derive the formula which is given in section 5.1, paragraph 3 of this paper
$$\frac{\mathrm{d}\langle g(s,x)\rangle_q}{\mathrm{d}v}=\frac{-1}{2v}(\big(\langle x\sigma(x)\rangle_q-m\langle\sigma(x)\rangle_q\big)$$
$$\frac{\mathrm{d}\langle g(s,x)\rangle_q}{\mathrm{d}m}=s-\langle\sigma(x)\rangle_q.$$
 where $q$ is the normal distribution. Does this derivation come from the direct partial differentiation of integrand with respect to $v$ and $m$? Could anybody suggest a way to re-derive these two equations?
 A: Notice that $g(s,x)=(s-1)x+\ln\sigma(x)$. So 
$$\langle g(s,x)\rangle_q=(s-1)m+\langle \ln\sigma(x)\rangle_q$$
and the entire $s$-dependence is trivial. Now for the second identity we perform a partial integration (noting that, since ${\cal N}$ is a function of $x-m$, one has $\partial{\cal N}/\partial m=-\partial {\cal N}/\partial x$),
$$\frac{\mathrm{d}\langle g(s,x)\rangle_q}{\mathrm{d}m}=s-1+\left\langle\frac{d}{dx}\ln\sigma(x)\right\rangle_q=s-1+\left\langle\frac{1}{1+e^x}\right\rangle_q=s-\left\langle\sigma(x)\right\rangle_q.$$
For the first identity it is convenient to change variables from $x$ to $y=(x-m)/\sqrt v$, so that we can replace ${\cal N}(x,m,v)$ by ${\cal N}(y,0,1)$ and $\sigma(x)$ by $\sigma(m+y\sqrt v)$. Then we carry out the derivative of $\ln\sigma$ with respect to $v$,
$$\frac{\mathrm{d}\langle g(s,y)\rangle_q}{\mathrm{d}v}=\left\langle\frac{y}{2 \sqrt{v}} \left(e^{m+y\sqrt{v} }+1\right)^{-1}\right\rangle_q=\left\langle\frac{y}{2 \sqrt{v}} \left(1-\sigma(m+y\sqrt v)\right)\right\rangle_q$$
$$=\left\langle\frac{x-m}{2 v} \left(1-\sigma(x)\right)\right\rangle_q=\frac{1}{2v}\langle (m-x)\sigma(x)\rangle_q,$$
in agreement with the first equation in the OP.
