3

The Leibniz integral rule states

$$ {\displaystyle {\frac {d}{dx}}\left(\int _{a}^{b}f(x,t)\,dt\right)=\int _{a}^{b}{\frac {\partial }{\partial x}}f(x,t)\,dt} $$

when the integral bounds are not a function of $x$, i.e. the variable we take the derivative with respect to.

An expectation of a continuous random variable or with respect to a continuous distribution is defined as an integral. More precisely, let $X$ be a continuous r.v. and $p(x)$ be its parametrized (by $\theta$) density, then we have

$$ \mathbb{E}_{p_{\theta}(x)}\left[ f(x) \right] = \int p_{\theta}(x) f(x) dx $$

In certain cases, you need to take the derivative of an expectation with respect to the parameters $\theta$ (e.g. this is common in certain machine learning problems)

$$\frac{d}{d \theta}\mathbb{E}_{p_{\theta}(x)}\left[ f(x) \right]$$

So, some people, in certain papers, seem to apply the Leibniz integral rule to get

\begin{align} \frac{d}{d \theta}\mathbb{E}_{p_{\theta}(x)}\left[ f(x) \right] & \stackrel{?}{=} \mathbb{E}_{p_{\theta}(x)}\left[ \frac{d}{d \theta} f(x) \right] \\ & \stackrel{?}{=} \int \frac{d}{d \theta} \left[ f(x) p_{\theta}(x) \right] dx \\ \end{align}

Some papers that say that we can bring the derivative inside the expectation because of the dominated convergence theorem, which I am not familiar with, so I would like someone to clarify me the relationship between the Leibniz integral rule above and the dominated convergence (specifically, in the context of taking derivatives of expectations, i.e. probability theory and statistics). Is the DCT just the way to prove the Leibniz integral rule? If that's true, can you show that?

Moreover, if you see above, I have $\mathbb{E}_{p_{\theta}(x)}\left[ \frac{d}{d \theta} f(x) \right] \stackrel{?}{=} \int \frac{d}{d \theta} \left[ f(x) p_{\theta}(x) \right] dx$, however, $p_{\theta}(x) \frac{d}{d \theta} f(x) \neq \frac{d}{d \theta} \left[ f(x) p_{\theta}(x) \right]$, so I suspect I've done something wrong or that the DCT and Leibniz integral rule are not applicable to the same contexts, i.e. maybe the Leibniz integral rule is not directly applicable to expectations because they involve random variables and densities?

3 Answers3

3

What you want to do is to bring the limit operation inside the integral sign. This cannot be done in general; one classic counterexample is that if

$$f_n(x)=\begin{cases} n & x \in [0,1/n] \\ 0 & \text{otherwise} \end{cases}$$

then $$\lim\limits_{n \to \infty} \int_0^1 f_n(x) dx = 1$$ but $$\int_0^1 \lim\limits_{n \to \infty} f_n(x) dx = 0$$ The Leibniz rule for fixed limits can be justified by the use of the dominated convergence theorem, which is the most widely used method to prove that one can interchange limit and integral. It works fine in the setting of probability theory since it is based on the Lebesgue integral (which is how expectation is usually defined in probability theory).

As for the rest of your question, passing $\frac{d}{d\theta}$ through $\mathbb{E}_{p_\theta}$ is definitely not valid, but $\frac{d}{d\theta} \mathbb{E}_{p_\theta}[f(X)]=\int \frac{d}{d\theta} \left [ f(x) p_\theta(x) \right ] dx$ is correct (assuming $p_\theta$ is the density function of the distribution of $X$).

Ian
  • 105,152
  • So, are you confirming that the DCT is used to prove the Leibniz integral rule? –  Jul 24 '20 at 14:50
  • 1
    @nbro Sure, though it's not the only way to do it. – Ian Jul 24 '20 at 14:50
  • I just found an article, where the derivative is brought inside the expectation: $\nabla_{\theta} \mathbb{E}{p(\epsilon)}[f(g(\epsilon, \theta))]=\mathbb{E}{p(\epsilon)}\left[\nabla_{\theta} f(g(\epsilon, \theta))\right]$. How do you explain this? This article was written by a research in statistical machine learning and works at DeepMind: Shakir Mohamed, who also wrote this review: https://arxiv.org/pdf/1906.10652.pdf. –  Jul 26 '20 at 19:42
  • Never mind. It's correct. He applied the product rule implicitly. The gradient of $\theta$ with respect to $\epsilon$ will be zero, so that term will cancel out. –  Jul 26 '20 at 19:54
  • @nbro Then the derivative only hits the integrand, not the "measure". – Ian Jul 26 '20 at 19:55
  • I am not sure what you mean by that, but I explained above why that is correct in that case. –  Jul 26 '20 at 19:59
  • @nbro It doesn't "really" have anything to do with the product rule, the point is that the derivative can be passed through because the measure that you're integrating with respect to depends only on $\epsilon$ and not $\theta$. – Ian Jul 26 '20 at 20:02
  • And I can show with the product rule that holds. See here: http://mathb.in/43875. –  Jul 26 '20 at 20:10
  • @nbro Right, my point is that it doesn't require the fact that the distribution is continuous. – Ian Jul 26 '20 at 20:34
2

We wish to prove $$ {\displaystyle {\frac {\partial }{dx}}\left(\int _{a}^{b}f(x,t)\,dt\right)=\int _{a}^{b}{\frac {\partial }{\partial x}}f(x,t)\,dt}. $$ We assume that $f:[c,d]\times T\to \mathbb{R}$ and $f(x, \cdot)$ is integrable for each $X$. Further assume that there exists $g\in L^1$ such that $|\frac{\partial f}{\partial x} (x,t)|\leq g(t)$ for all $x$ and $t$. Let $F(x)=\int_a^b f(x,t) \,dt$.

To this end put $h_n(t)=\frac{f(x_n, t)-f(x_0, t)}{x_n-x_0}$ where $x_n\to x_0$. Then $ h_n(t)\to \frac{\partial f}{\partial x}(x_0, t) $ as $n\to \infty$. Further $$ |h_n(t)|\leq \sup_{x\in[c, d]}|\frac{\partial f}{\partial x} (x,t)|\leq g(t) $$ Hence the dominated convergence theorem implies that $$ F'(x_0)=\lim_{n\to\infty}\frac{F(x_n)-F(x_0)}{x_n-x_0}=\lim\int_a^b h_n(t)\,d t=\int_a^b \frac {\partial }{\partial x} f(x,t)\, dt $$ where in the last line we use the dominated convergence theorem.

0

First :

$\frac{df(x)}{d\theta}=0$ is zero since $f$ doesn't depends on $\theta$.

So your problem is rewritten like this :

There is two things to distinguish :

1-Dominated convergence theorem

Let a sequence of function $f_n$ : $X \to Y$, converging pointwise to $f$ such that :

  • There exists integrable $g$ such that for almost all $\forall n \in \mathbb{N}$ , $x \in X$ , $|f_n(x)|\leq |g(x)|$

It follows that we can define the integral of $f$ :

$$ \int f \triangleq\lim_\infty \int f_n = \int \lim_\infty f_n = $$


Now the Leibniz derivation rule is another theorem. (known as derivation under the sign) in which we use DCT to show it.


2-Leibniz derivation rule

Taking a function $p:\Theta \times X \to Y $ veryfing the follow conditions :

  • For all x $x\in X$, la fonction $\theta \mapsto p(\theta,x)$ is continous by part over $\Theta$ and integrable over $\Theta$;
  • $p$ admits partial derivative $\frac{\partial p}{\partial x}$ defined on $\Theta\times X$;
  • For all $x\in X$, the fonction $\theta \mapsto \frac{\partial p}{\partial x}(\theta,x)$ is continous by part over $\Theta$;
  • For all $\theta \in \Theta$, the fonction $x\mapsto \frac{\partial p}{\partial x}(\theta,x)$ est continue sur $X$;
  • There exists $g:\Theta\to\mathbb R_+$ continous by part and integrable, such that for all $x\in X$ and for all $\theta\in \Theta$, $$\left|\frac{\partial p}{\partial x}(\theta,x)\right|\leq g(\theta).$$
  • EDX
    • 2,423