This is the density function and random generation from the continuous relaxation of a Markov random field (MRF) distribution.

```
dcrmrf(x, alpha, Omega, log=FALSE)
rcrmrf(n, alpha, Omega)
```

x

This is a vector of length \(k\).

n

This is the number of random deviates to generate.

alpha

This is a vector of length \(k\) of shape parameters.

Omega

This is the \(k \times k\) precision matrix \(\Omega\).

log

Logical. If `log=TRUE`

, then the logarithm of the
density is returned.

`dcrmrf`

gives the density and
`rcrmrf`

generates random deviates.

Application: Continuous Multivariate

Density: $$p(\theta) \propto \exp(-\frac{1}{2} \theta^T \Omega^{-1} \theta) \prod_i (1 + \exp(\theta_i + alpha_i))$$

Inventor: Zhang et al. (2012)

Notation 1: \(\theta \sim \mathcal{CRMRF}(\alpha, \Omega)\)

Notation 2: \(p(\theta) = \mathcal{CRMRF}(\theta | \alpha, \Omega)\)

Parameter 1: shape vector \(\alpha\)

Parameter 2: positive-definite \(k \times k\) matrix \(\Omega\)

Mean: \(E(\theta)\)

Variance: \(var(\theta)\)

Mode: \(mode(\theta)\)

It is often easier to solve or optimize a problem with continuous variables rather than a problem that involves discrete variables. A continuous variable may also have a gradient, contour, and curvature that may be useful for optimization or sampling. Continuous MCMC samplers are far more common.

Zhang et al. (2012) introduced a generalized form of the Gaussian integral trick from statistical physics to transform a discrete variable so that it may be estimated with continuous variables. An auxiliary Gaussian variable is added to a discrete Markov random field (MRF) so that discrete dependencies cancel out, allowing the discrete variable to be summed away, and leaving a continuous problem. The resulting continuous representation of the problem allows the model to be updated with a continuous MCMC sampler, and may benefit from a MCMC sampler that uses derivatives. Another advantage of continuous MCMC is that stationarity of discrete Markov chains is problematic to assess.

A disadvantage of solving a discrete problem with continuous parameters is that the continuous solution requires more parameters.

Zhang, Y., Ghahramani, Z., Storkey, A.J., and Sutton, C.A. (2012).
"Continuous Relaxations for Discrete Hamiltonian Monte Carlo".
*Advances in Neural Information Processing Systems*, 25,
p. 3203--3211.

```
# NOT RUN {
library(LaplacesDemon)
x <- dcrmrf(rnorm(5), rnorm(5), diag(5))
x <- rcrmrf(10, rnorm(5), diag(5))
# }
```

Run the code above in your browser using DataLab