Partial derivatives for box integral of a bivariate normal distribution

bivariate-distributionsmultivariable-calculusnormal distributionpartial derivativestatistics

I'm having quite a bit of trouble trying to understand how to to calculate partial derivatives of a specific function.

Suppose I have the standard bivariate normal density function:

$$\begin{eqnarray}
f(x,y,\rho)&=&\phi_2\left(x,y \text{ }\bigg| \text{ }\text{mean}=\begin{bmatrix}
0 \\ 0 \end{bmatrix} ,\text{cov}=\begin{bmatrix}
1 & \rho \\ \rho & 1 \end{bmatrix} \right) \\
&=&\frac{1}{2\pi\sqrt{1-\rho^2}}\exp \left(-\frac{x^2-2\rho x y + y^2}{2(1-\rho^2)}\right)
\end{eqnarray}$$

where $\rho$ is the correlation term between $x$ and $y$.

I then create a function $F$ that represents the box integral of $f$ for $x\in\left[x_{\text{L}},x_{ \text{U}}\right]$ and $y\in\left[y_{\text{L}},y_{ \text{U}}\right]$:

$$F(x_{\text{L}},x_{ \text{U}},y_{ \text{L} },y_{ \text{U} },\rho)=\int_{x_{ \text{L} }}^{x_{ \text{U} }}\int_{y_{ \text{L} }}^{y_{ \text{U} }}f(x,y,\rho)dydx$$

The derivatives I'm interested in finding are:

$$\frac{\partial F}{\partial x_{ \text{L} }}, \frac{\partial F}{\partial x_{ \text{U} }}, \frac{\partial F}{\partial y_{ \text{L} }}, \frac{\partial F}{\partial y_{ \text{U} }}, \frac{\partial F}{\partial \rho}$$

How on earth do I go about finding these derivatives?

I know that closed form integrals for the univariate, bivariate or multivariate normal density functions simply do not exist. But does that mean that I cannot calculate these partial derivatives either?

Thank you!


Edit

I've been able to make a lot of progress using the Leibniz Integral Rule, aka differentiation under the integral sign. Shout out to @eyeballfrog for the tip that I only need to use the one-dimension case.

I've been able to find values for $\frac{\partial F}{\partial x_{ \text{L} }}$, $ \frac{\partial F}{\partial x_{ \text{U} }} $ , $\frac{\partial F}{\partial y_{ \text{L} }}$ and $\frac{\partial F}{\partial y_{ \text{U} }}$. However, I seem to have run into a snag for the partial derivative with respect to the correlation term, $\frac{\partial F}{\partial \rho}$.

Here is how far I've gotten:

$$\frac{\partial F}{\partial \rho} = \int_{x_{ \text{L} }}^{x_{ \text{U} }}\int_{y_{ \text{L} }}^{y_{ \text{U} }} \frac{\partial}{\partial \rho} f(x,y,\rho)dydx$$

The tricky thing is that $\frac{\partial F}{\partial \rho} $ is SUPER messy. Here's what it looks like:

$$\begin{eqnarray}
\frac{\partial F}{\partial \rho} &=& \int_{x_{ \text{L} }}^{x_{ \text{U} }}\int_{y_{ \text{L} }}^{y_{ \text{U} }} \frac{\rho^3 – \rho^2 x y +\rho x^2 + \rho y^2 – \rho – xy}{2 \pi (\rho-1)(\rho + 1) (1 – \rho^2)^{3/2}} \cdot \text{exp} \left( -\frac{x^2}{2(1-\rho^2)} + \frac{\rho x y}{1-\rho^2} -\frac{y^2}{2(1-\rho^2)} \right)dydx
\end{eqnarray}$$

So it seems very unlikely that I'll get a nice "closed-form" solution for the double integral of $\frac{\partial F}{\partial \rho} $.

Does anyone see some sort of simplification that can be done here? For example, does $\frac{\partial F}{\partial \rho} $ contain the kernel of a modified bivariate normal distribution, or something like that? Because I honestly cannot see it here.

Thanks!!!

Best Answer

To answer this question, we will need to have access to the univariate normal density ($\phi_1$) and probability ($\Phi_1$) functions. For the sake of completeness, here are their definitions. Assuming a random variable $Z$ is normally distributed with mean $\mu$ and variance $\sigma^2$, we have:

$$\begin{equation} Z\sim \mathcal{N}(\mu,\sigma^2) \Rightarrow \begin{cases} & \text{dens}(Z=z)=\phi_1\left(z|\text{mean}=\mu,\text{var}=\sigma^2\right) = \frac{1}{\sigma\sqrt{2\pi}} e^{-\frac{1}{2}\left(\frac{z - \mu}{\sigma}\right)^2} \\ & \text{prob}(Z<=z)=\Phi_1\left(z|\text{mean}=\mu,\text{var}=\sigma^2\right) = \frac{1}{2}\left[1 + \text{erf}\left( \frac{x-\mu}{\sigma\sqrt{2}}\right)\right] \\ \end{cases} \end{equation}$$

Now that we have access to $\phi_1$ and $\Phi_1$, we can write out the partial derivatives as follows:

$$\begin{eqnarray} \frac{\partial F}{\partial x_{ \text{L} }} = (-1) &\cdot& \left[\Phi_1\left(y_U|\text{mean}=\rho \cdot x_{ \text{L} }, \text{var} = 1-\rho^2 \right) - \Phi_1\left(y_{ \text{L} }|\text{mean}=\rho \cdot x_{ \text{L} }, \text{var} = 1-\rho^2 \right)\right] \\ &\cdot& \phi_1 \left(x_{ \text{L} }|\text{mean}=0,\text{var}=1 \right) \end{eqnarray}$$

$$\begin{eqnarray} \frac{\partial F}{\partial x_{ \text{U} }} = (+1) &\cdot& \left[\Phi_1\left(y_U|\text{mean}=\rho \cdot x_U, \text{var} = 1-\rho^2 \right) - \Phi_1\left(y_{ \text{L} }|\text{mean}=\rho \cdot x_U, \text{var} = 1-\rho^2 \right)\right] \\ &\cdot& \phi_1 \left(x_U|\text{mean}=0,\text{var}=1 \right) \end{eqnarray}$$

$$\begin{eqnarray} \frac{\partial F}{\partial y_{ \text{L} }} = (-1) &\cdot& \left[\Phi_1\left(x_U|\text{mean}=\rho \cdot y_{ \text{L} }, \text{var} = 1-\rho^2 \right) - \Phi_1\left(x_{ \text{L} }|\text{mean}=\rho \cdot y_{ \text{L} }, \text{var} = 1-\rho^2 \right)\right] \\ &\cdot& \phi_1 \left(y_{ \text{L} }|\text{mean}=0,\text{var}=1 \right) \end{eqnarray}$$

$$\begin{eqnarray} \frac{\partial F}{\partial y_{ \text{U} }} = (+1) &\cdot& \left[\Phi_1\left(x_U|\text{mean}=\rho \cdot y_U, \text{var} = 1-\rho^2 \right) - \Phi_1\left(x_{ \text{L} }|\text{mean}=\rho \cdot y_U, \text{var} = 1-\rho^2 \right)\right] \\ &\cdot& \phi_1 \left(y_U|\text{mean}=0,\text{var}=1 \right) \end{eqnarray}$$

$$\begin{eqnarray} \frac{\partial F}{\partial \rho} = f\left(x_\text{U},y_\text{U},\rho \right) - f\left(x_\text{U},y_\text{L},\rho \right) - f\left(x_\text{L},y_\text{U},\rho \right) + f\left(x_\text{L},y_\text{L},\rho \right) \end{eqnarray}$$

In the last partial derivative $\left(\frac{\partial F}{\partial \rho}\right)$, the $f$ function being referenced is, as defined at the top of the original question, the standard bivariate normal density function:

$$f(x,y,\rho)=\phi_2\left(x,y \text{ }\bigg| \text{ }\text{mean}=\begin{bmatrix} 0 \\ 0 \end{bmatrix} ,\text{cov}=\begin{bmatrix} 1 & \rho \\ \rho & 1 \end{bmatrix} \right)$$

The solution provided above relies heavily on the math found in this other Stack Exchange post and, as pointed out in the comments above, the Leibniz Integral Rule (a.k.a differentiation under the integral sign), and A LOT of Wolfram Alpha. Special thanks to @eyeballfrog for pointing me in the right direction.

PS: Apologies for the weird formatting and alignment in some places. It's difficult to find a good way to visually represent these long equations.