ODE's: Continuity Equation

419 Views Asked by At

The context of this question is Machine Learning (more specifically, my question results from this paper, yet I have a math question, so I'm posting it here). First of all, some definitions (Sec. 2 of the mentioned paper):


Let $\mathbb{R}^{d}$ denote the data space with data points $x = (x^{1}$, $\dots$, $x^{d})\in\mathbb R^{d}$. Two important objects we use in this paper are: the probability density path $p: [0, 1]\times\mathbb R^{d} \rightarrow \mathbb R_{> 0}$, which is a time dependent probability density function, i.e. $\int p_{t}(x)dx = 1$, and a time-dependent vector field, $v: [0, 1]\times \mathbb R^{d}\rightarrow\mathbb R^{d}$. A vector field $v_{t}$ can be used to construct a time-dependent diffeomorphic map, called a flow, $\phi: [0, 1]\times \mathbb R^{d} \rightarrow \mathbb R^{d}$, defined via the ordinary differential equation (ODE):

$$\frac{d}{dt}\phi_{t}(x) = v_{t}(\phi_{t}(x)) \tag{1}\label{eq:cnf}$$

$$\phi_{0}(x) = x\tag{2}$$ [...] A CNF [Continuous Normalizing Flow] is used to reshape a simple prior density $p_{0}$ density (e.g., pure noise) to a more complicated one, $p_{1}$, via the push-forward equation

$$\tag{3}\label{eq:push_forward} p_{t} = \left[\phi_{t}\right]_{\star}p_{0}$$

where the push-forward (or change of variables) operator $\star$ is defined by $$\left[\phi_{t}\right]_{\star}p_{0}(x) = p_{0}(\phi_{t}^{-1}(x))\det\left[ \frac{\partial \phi_{t}^{-1}}{\partial x}(x) \right].$$ A vector field $v_{t}$ is said to generate a probability density path $p_{t}$ if its flow $\phi_{t}$ satisfies equation $\eqref{eq:push_forward}$. One practical way to test if a vector field generates a probability path is using the continuity equation [...], see Appendix B.

The continuity equation given in App. B is (cf. Eq. (26)):

$$\tag{26}\label{eq:continuity}\frac{d}{dt}p_{t}(x) + \text{div}(p_{t}(x)v_{t}(x)) = 0,$$ where $\text{div} = \sum_{i=1}^{d}\frac{\partial}{\partial x^{i}}$


I'd like to show that the $v_{t}$ from Eq.$\eqref{eq:cnf}$ satisfies the continuity equation $\eqref{eq:continuity}$ (this should kinda trivially hold by definition, but I'd like to do it explicitly via the continuity equation).

The LHS of $\eqref{eq:continuity}$ is: $$\frac{d}{dt}p_{t}(x) = \frac{d}{dt}\left( p_{0}(\phi_{t}^{-1}(x))\det\left[ \frac{\partial \phi_{t}^{-1}}{\partial x}(x) \right]\right)$$ and the RHS $$\text{div}(p_{t}(x)v_{t}(x)) = \text{div}\left(p_{0}(\phi_{t}^{-1}(x))\det\left[ \frac{\partial \phi_{t}^{-1}}{\partial x}(x) \right]\frac{dx}{dt}\right)$$ Now, on the LHS, we have the time-derivative of the determinant, but not on the RHS, so I was wondering whether I'm on the right track?

Any help would be appreciated.

2

There are 2 best solutions below

2
On

To show this, one can use the measure-theoretic change of variables formula, namely for any measurable function $g$ we have $$\int g(\phi(y))p_t(y)dy = \int g(x)p_0(x)dx$$ since $p_t=[\phi]_{\star}p_0$.

Now we will try to formulate the continuity equation as an integral equation: Let $\psi\in\mathcal C_c^\infty((0,\infty)\times\mathbb R^n)$ be any test function. Then multiplying the continuity equation by $\psi$ and integrating yields

$$\int_0^T\int_{\mathbb R^n} \psi\partial_t p_tdxdt =-\int_0^T\int_{\mathbb R^n} \psi \text{div}(p\cdot v_t)dxdt$$ which, after applying integration by parts, is equivalent to (for details see edit below)

$$\bigg[\int_{\mathbb R^n}\psi p_tdx\bigg]_{t=0}^{t=T} -\int_0^T \partial_t\psi p_tdxdt=\int_0^T\nabla\psi \cdot v_t p_tdxdt$$

Therefore we can show that $(p,v)$ solves the continuity equation by verifying the integral equation $$\int_{\mathbb R^n}\psi p_Tdx-\int_{\mathbb R^n}\psi p_0dx=\int_0^T\int_{\mathbb R^n}(\partial_t\psi)p_t + v_t\cdot\nabla\psi p_tdxdt$$

To do this, we compute the derivative \begin{align*}\frac{d}{dt}\int_{\mathbb R^n}\psi p_tdx&=\frac{d}{dt}\int_{\mathbb R^n}\psi(t,\phi_t(y))p_0(y)dy=\int_{\mathbb R^n}\frac{d}{dt}\psi(t,\phi_t(y))p_0(y)dy \\\\ (\text{chain rule}) &=\int_{\mathbb R^n} \bigg[\partial_t\psi(t,\phi_t(y))+\nabla\psi(t,\phi_t(y))\cdot \partial_t\phi_t(y)\bigg]p_0(y)dy \\\\ (\partial_t\phi_t=v_t\circ\phi_t)&=\int_{\mathbb R^n}\bigg[\partial_t\psi(t,\phi_t(y))+\nabla \psi(t,\phi_t(y)\cdot v_t(\phi_t(y))\bigg]p_0(y)dy \\\\ (\text{change of variables}) &= \int_{\mathbb R^n}\bigg[\partial_t\psi(t,x)+\nabla\psi(t,x)\cdot v_t(x)\bigg]p_t(x)dx \end{align*} and thus by applying the fundamental theorem of calculus to this derivative we have shown the integral formulation of the continuity equation.

EDIT

Here are some more details about the integration by parts performed above:
Note that since $\psi$ has compact support, we can simply integrate over $\text{supp}\psi$ instead of all of $\mathbb R^n$. Letting $\Omega=\text{supp}\psi$ and $\partial \Omega$ be the boundary of $\Omega$, integration by parts states that $$\int_\Omega \psi\cdot \text{div}(v_t\cdot p_t)dx=\int_{\partial\Omega}\psi\cdot v_t\cdot \hat\eta p_td\sigma-\int_\Omega \nabla\psi \cdot v_tp_tdx$$ where $\hat\eta$ is the outer normal on $\partial\Omega$ and $\sigma$ is the surface measure on $\partial\Omega$. Now by continuity of $\psi$ we have that $\psi=0$ on $\partial\Omega=\partial\text{supp}\psi$, hence the first term vanishes. Again, we can without any problem replace the domain of integration $\Omega$ by $\mathbb R^n$ and obtain: $$\int_{\mathbb R^n} \psi\cdot\text{div}(v_tp_t)dx=-\int_{\mathbb R^n}\nabla\psi\cdot v_t p_t dx.$$

0
On

I think my answer will be better if we know what exactly the Jacobian determinant of the flow look like:).

First of all, about the flow $\phi_t(x)$ and its Jacobian Matrix $M_t(x)$, we can prove an equation $\frac{d}{dt}M_t(x)=Dv_t(\phi_t(x))M_t(x)$ (by using chain rule to find the i-j-th element of $\frac{d}{dt}M_t(x)$).

Then we also know the initial of $M_t(x)$: $M_0(x)=D\phi_0(x)=DI(x)=I$.

So we get an IVP in matrix form, and it is easy to solve! So we obtain the expression of $M_t(x)$: \begin{align} M_t(x)=\exp(\int_{0}^{t}Dv_s(x_s)ds) \end{align} where $x_s=\phi_s(x)$.

Then the determinant comes that \begin{align} J_t(x)=\det(M_t(x))=\det(\exp(\int_{0}^{t}Dv_s(x_s)ds))\\ =\exp(\text{tr}(\int_{0}^{t}Dv_s(x_s)ds))=\exp(\int_{0}^{t}\text{div}(v_s(x_s))ds), \end{align} where we use the fact that $\det(\exp(X))=\exp(\text{tr}(X))$.

Now two densities should satisfy: \begin{align} p_t(x_t)J_t(x_0)=p_0(x_0). \end{align} (I use $x_0$ to avoid the confusion may be caused.)

Then the equation you want could be much more clear if we multiply it by $J_t(x_0)$: \begin{equation} \begin{aligned} &\qquad J_t({x}_0)\cdotp\left[\partial_tp_t({x}_t)+\text{div}({v}_t({x}_t)p_t({x}_t))\right]\\ &=\partial_tp_t({x}_t)\cdotp J_t({x}_0)+\text{div}({v}_t({x}_t)p_t({x}_t)J_t({x}_0))\\ &=\partial_t(p_t({x}_t)J_t({x}_0))-p_t({x}_t)\cdotp\partial_tJ_t({x}_0)+\text{div}({v}_t({x}_t)p_0({x}0))\\ &=\partial_tp_0({x}_0)-p_t({x}_t)\cdotp\partial_tJ_t({x}_0)+\text{div}({v}_t({x}_t)p_0({x}_0))\\ &=-p_t({x}_t)\cdotp\frac{d}{dt}\exp(\int_{0}^{t}\text{div}({v}_s({x}_s))ds)+p_0({x}_0)\cdotp\text{div}({v}_t({x}_t))\\ &=-p_t({x}_t)\cdotp\exp(\int_{0}^{t}\text{div}({v}_s({x}_s))ds)\cdotp\text{div}({v}_t({x}_t))+p_0({x}_0)\cdotp\text{div}({v}_t({x}_t))\\ &=-p_t({x}_t)\cdotp J_t({x}_0)\cdotp\text{div}({v}_t({x}_t))+p_0({x}_0)\cdotp\text{div}({v}_t({x}_t))=0. \end{aligned} \end{equation}

I will be glad if my answer could help! (btw I'm not very confident about my English and writing, so plz ignore all of my language mistakes x_x.)


The process I show above is to verify the equation if you already know it. However, it may be not that good if you want to build it from nothing and we can do it with the fact that $\frac{d}{dt}\mathbb{E}f(X_t)=\mathbb{E}\frac{d}{dt}f(X_t)$ where $f$ is a test function (ATTENTION: now I am going to FIND the equation but not to PROVE it.):

\begin{align} \frac{d}{dt}\mathbb{E}f({X}_t)=\frac{d}{dt}\int_{\mathbb{R}^d}f({x})p_t({x})d{x}=\int_{\mathbb{R}^d}f({x})\partial_tp_t({x})d{x}, \end{align} \begin{equation} \begin{aligned} \mathbb{E}\frac{d}{dt}f({X}_t)&=\int_{\mathbb{R}^d}\text{grad} f({x}_t){v}_t({x}_t)p_t({x}_t)d{x}_t\\ &=0-\int_{\mathbb{R}^d} f({x}_t)\text{div}({v}_t({x}_t)p_t({x}_t))d{x}_t\\ &=\int_{\mathbb{R}^d} -f({x})\text{div}({v}_t({x})p_t({x}))d{x}. \end{aligned} \end{equation} By the fundamental lemma of calculus of variation, $p_t$ satisfies \begin{align} \partial_tp_t({x})+\text{div}({v}_t({x})p_t({x}))=0.\label{YY} \end{align}