Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3. Random fields in CUQIpy

In many inverse problems, the quantity we want to infer is not a single number but a field, such as an image or a spatially or temporally varying temperature of an object. Such fields are rarely arbitrary: physical quantities tend to vary smoothly, and neighboring values are correlated with each other.

This notebook presents the Gaussian Markov random field (GMRF) in CUQIpy and lists other random fields available in the package. We will briefly explain the intuition behind GMRF and its use within CUQIpy.

Notebook Cell

3.1. Motivation

As a first attempt, consider modeling a field x=[x1,…,xn]T\mathbf{x} = [x_1, \dots, x_n]^T with an i.i.d. Gaussian prior, i.e. each element is independent with the same precision dd:

xi∼Gaussian(0,d−1),independently for i=1,…,n.x_i \sim \mathrm{Gaussian}(0, d^{-1}), \qquad \text{independently for } i = 1, \dots, n.

A sample from this prior looks like white noise:

<Figure size 1000x300 with 1 Axes>

One issue of such a field is that the neighboring values are unrelated. To build correlation into the prior, we need a different construction and this is what the GMRF provides.

3.2. A first look at samples

With the same elementwise precision d=50d = 50 as the i.i.d. Gaussian above, we define the GMRF prior as follows:

Both priors use the same elementwise precision d=50d = 50, so any difference between their samples is due to correlation structure alone. Compare the GMRF sample below with the i.i.d. sample above: it varies smoothly, with neighboring values close together.

<Figure size 1000x300 with 1 Axes>

3.3. Definition: the Gaussian Markov random field

The key idea of the Markov random field is to put the prior on the differences between neighboring elements rather than on the elements themselves. Particularly in GMRF, we assume that the difference between neighboring elements follows a zero-mean Gaussian with precision dd,

xi−xi−1∼Gaussian(0,d−1),i=1,…,n,\begin{align*} x_i - x_{i-1} \sim \mathrm{Gaussian}(0, d^{-1}), \quad i=1, \ldots, n, \end{align*}

This induces a joint Gaussian distribution on x\mathbf{x} which we denote by GMRF(0,d)\mathrm{GMRF}(\mathbf{0}, d) — a Gaussian with mean 0\mathbf{0} and precision dd on the neighbor differences. The distribution is implemented in CUQIpy as the GMRF class. For more details on the GMRF, see the CUQIpy paper Riis et al. (2024). The name Markov random field refers to the conditional independence structure of the distribution. For an interior node of our GMRF in 1D, the conditional distribution of xix_i given all other nodes is given by

p(xi∣xj≠i)=N ⁣(xi−1+xi+12,  12d)p(x_i \mid x_{j \neq i}) = \mathcal{N}\!\left(\frac{x_{i-1} + x_{i+1}}{2},\; \frac{1}{2d}\right)

In general, the GMRF defines a zero-mean multivariate Gaussian distribution with precision matrix

P=d DTD,\mathbf{P} = d\, \mathbf{D}^T \mathbf{D},

where D\mathbf{D} is the difference matrix. Particularly, the precision matrix P\mathbf{P} is tridiagonal: its only non-zero entries lie on the main diagonal and the two adjacent diagonals. This sparsity is particularly attractive computationally and is part of the reason why GMRFs are often used as priors in imaging problems.

3.4. Other Markov random fields in CUQIpy

CMRF and LMRF are similar to GMRF but with different distributions on the differences between neighboring elements in the signal, where CMRF assumes a Cauchy distribution and LMRF assumes a Laplace distribution. LMRF and CMRF are particularly useful in cases in which the signal to be inferred has sharp edges (jumps). While both LMRF and CMRF favor small differences between neighboring elements, the heavy-tailed LMRF assigns substantially more mass to large differences, making it more suitable when occasional large jumps are expected. Their resulting non-Gaussian posteriors can, however, be more challenging to sample from.

This 1D deconvolution example from Riis et al. (2024) illustrates and compares using the three Markov random fields in a 1D problem.

We have additional approaches to define random fields in CUQIpy through geometry objects. These objects utilize KL expansion to construct random fields with desired correlation properties. For examples on using these fields in inverse problems, we refer the reader to Chapter 13: PDE-based BIP.

References
  1. Riis, N. A. B., Alghamdi, A. M. A., Uribe, F., Christensen, S. L., Afkham, B. M., Hansen, P. C., & Jørgensen, J. S. (2024). CUQIpy: I. Computational uncertainty quantification for inverse problems in Python. Inverse Problems, 40(4), 045009. 10.1088/1361-6420/ad22e7