Gradient of a function with integral

87 Views Asked by At

Let $\mathbf{x}$ be a $n\times 1$ vector. Let $\mu(\mathbf{x})$ and $\sigma(\mathbf{x})$ be scalar functions of $\mathbf{x}$. What is the derivative of the following function w.r.to $\mathbf{x}$ $$f(\mathbf{x})=\int_{-\infty}^{0} \exp(-\frac{(z-\mu(\mathbf{x}))^2}{\sigma^{2}(\mathbf{x})})dz$$

2

There are 2 best solutions below

0
On

For simplicity, let the function in the exponential be $\Gamma(z, \vec{x})$ and the function under the integral $f(z, \vec{x})$. The function in question is integrable for every $\vec{x}$. $\\$ The partial derivative with respect to $x_i$ of your function: $$ \partial_{x_i} = \exp (\Gamma(z, \vec{x}) \cdot \partial_{x_i}\Gamma(z, \vec{x}) = f(z, \vec{x}) \cdot \partial_{x_i}\Gamma(z, \vec{x}) $$ Since we're integrating on a different variable than any $x_i$, if the above is integrable over the same domain then you can switch derivatives and integrals, which means that the $i$-th component of the gradient: $$\nabla_i \int_\infty^0 f(z, \vec{x}) dz = \int_\infty^0 f(z, \vec{x}) \cdot \partial_{x_i}\Gamma(z, \vec{x}) dz $$ I believe one can find the final expression from here. I'll fill in the final details as soon as I have a piece of paper to sketch the final result.

0
On

$$\nabla_x f(x) = \int_{-\infty}^0\nabla_x \exp(-\frac{(z-\mu(x))^2}{\sigma(x)^2}) dz \\= \int_{-\infty}^0 \exp(-\frac{(z-\mu(x))^2}{\sigma(x)^2}) \left[2\frac{(z-\mu(x))\nabla_x \mu}{\sigma(x)^2} +2 \frac{(z-\mu(x))^2\nabla_x\sigma}{\sigma(x)^3}\right]dz$$.

The first part, $\propto \nabla_x\mu$, you may easily integrate by taking $\nabla_x\mu$ out of the integral and realizing

$$ 2\frac{(z-\mu(x))}{\sigma(x)^2} = \partial_z \frac{(z-\mu(x))^2}{\sigma(x)^2} $$

The second part has no closed form and may only be expressed in term of error-functions (as one may calculate by using the product rule und definition of $erf$): $$ \int x^2 \exp(-x^2)dx = \frac{1}{4}(\sqrt{\pi}erf(x)-2\exp(-x^2)x) + C $$