GMRF#

class cuqi.distribution.GMRF(mean=None, prec=None, bc_type='zero', order=1, **kwargs)#

Gaussian Markov random field (GMRF).

Parameters:
  • mean (array_like) – Mean of the GMRF.

  • prec (float) – Precision of the GMRF.

  • bc_type (str) – The type of boundary conditions to use. Can be ‘zero’, ‘periodic’ or ‘neumann’.

  • order (int) – The order of the GMRF. Can be 0, 1 or 2.

Notes

The GMRF defines a distribution over a set of points where each point conditioned on all the others follow a Gaussian distribution.

For 1D (physical_dim=1), the current implementation provides three different cases:

  • Order 0: \(x_i \sim \mathcal{N}(\mu_i, \delta^{-1})\),

  • Order 1: \(x_i \mid x_{i-1},x_{i+1} \sim \mathcal{N}(\mu_i+(x_{i-1}+x_{i+1})/2, (2\delta)^{-1}))\),

  • Order 2: \(x_i \mid x_{i-1},x_{i+1} \sim \mathcal{N}(\mu_i+(-x_{i-1}+2x_i-x_{i+1})/4, (4\delta)^{-1}))\),

where \(\delta\) is the prec parameter and the mean parameter is the mean \(\mu_i\) for each \(i\).

For 2D (physical_dim=2), order 0, 1, and 2 are also supported in which the differences are defined in both horizontal and vertical directions.

It is possible to define boundary conditions for the GMRF using the bc_type parameter.

Illustration as a Gaussian distribution

It may be beneficial to illustrate the GMRF distribution for a specific parameter setting. In 1D with zero boundary conditions, the GMRF distribution can be represented by a Gaussian, \(\mathcal{N}(\mu, \mathbf{P}^{-1})\), with mean \(\mu\) and the following precision matrices depending on the order:

  • Order 0:

\[\mathbf{P} = \delta \mathbf{I}.\]
  • Order 1:

\[\mathbf{P} = \delta \begin{bmatrix} 2 & -1 & & \newline -1 & 2 & -1 & \newline & \ddots & \ddots & \ddots \newline & & -1 & 2 \end{bmatrix}.\]
  • Order 2:

\[\mathbf{P} = \delta \begin{bmatrix} 6 & -4 & 1 & & & \newline -4 & 6 & -4 & 1 & & \newline 1 & -4 & 6 & -4 & 1 & \newline & \ddots & \ddots & \ddots & \ddots & \ddots \newline & & \ddots & \ddots & \ddots & \ddots \newline & & & 1 & -4 & 6 \newline \end{bmatrix}.\]

General representation

In general we can define the GMRF distribution on each point by

\[x_i \mid \mathbf{x}_{\partial_i} \sim \mathcal{N}\left(\sum_{j \in \partial_i} \beta_{ij} x_j, \kappa_i^{-1}\right),\]

where \(\kappa_i\) is the precision of each Gaussian and \(\beta_{ij}\) are coefficients defining the structure of the GMRF.

For more details see: See Bardsley, J. (2018). Computational Uncertainty Quantification for Inverse Problems, Chapter 4.2.

__init__(mean=None, prec=None, bc_type='zero', order=1, **kwargs)#

Initialize the core properties of the distribution.

Parameters:
  • name (str, default None) – Name of distribution.

  • geometry (Geometry, default _DefaultGeometry (or None)) – Geometry of distribution.

  • is_symmetric (bool, default None) – Indicator if distribution is symmetric.

Methods

__init__([mean, prec, bc_type, order])

Initialize the core properties of the distribution.

disable_FD()

Disable finite difference approximation for logd gradient.

enable_FD([epsilon])

Enable finite difference approximation for logd gradient.

get_conditioning_variables()

Return the conditioning variables of this distribution (if any).

get_mutable_variables()

Return any public variable that is mutable (attribute or property) except those in the ignore_vars list

get_parameter_names()

Returns the names of the parameters that the density can be evaluated at or conditioned on.

gradient(*args, **kwargs)

Returns the gradient of the log density at x.

logd(*args, **kwargs)

Evaluate the un-normalized log density function of the distribution.

logpdf(x)

Evaluate the log probability density function of the distribution.

pdf(x)

Evaluate the log probability density function of the distribution.

sample([N])

Sample from the distribution.

to_likelihood(data)

Convert conditional distribution to a likelihood function given observed data

Attributes

FD_enabled

Returns True if finite difference approximation of the logd gradient is enabled.

FD_epsilon

Spacing for the finite difference approximation of the logd gradient.

dim

Return the dimension of the distribution based on the geometry.

geometry

Return the geometry of the distribution.

is_cond

Returns True if instance (self) is a conditional distribution.

mean

name

Name of the random variable associated with the density.

prec

sqrtprec

sqrtprecTimesMean