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

⚠️ Content to be extended to cover other random fields as well, possibly including FEniCS KL fields

In some cases, we may want to generate samples that represent a field with some spatial correlation and smoothness properties.

One CUQIpy distribution object that can be achieved for this purpose is the Gaussian Markov random field (GMRF) distribution siden2020scalable. This distribution assumes a Gaussian distribution on the differences between neighboring elements of x\mathbf{x}, i.e. in 1D:

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

where we purposely leave out the details on the boundary conditions for this notebook.

To simplify the notation, we denote by GMRF\mathrm{GMRF} the distribution that induces this property on a vector x\mathbf{x} defined by its mean and precision dd. That is, the above can be written as

xGMRF(0,d),\begin{align*} \mathbf{x} &\sim \mathrm{GMRF}(\mathbf{0}, d), \end{align*}

with some choice of the precision say d=50d=50. For more details on GMRF see the CUQIpy paper (the first part of the 2-part article) Riis_2024.

The GMRF distribution is implemented in CUQIpy as GMRF class and can be used as follows:

Notebook Cell
from cuqi.distribution import GMRF
import numpy as np
# Define prior precision
d = 50
n = 200
# Define GMRF prior (zero boundary conditions are the default)
x_GMRF = GMRF(np.zeros(n), d)
# your code here

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).

This 1D deconvolution example from Riis_2024 illustrates and compares using the three Markov random fields in a 1D problem.