# dist.ContinuousRelaxation: Continuous Relaxation of a Markov Random Field Distribution In LaplacesDemon: Complete Environment for Bayesian Inference

## Description

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

## Usage

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

## Arguments

 `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 x k precision matrix Omega. `log` Logical. If `log=TRUE`, then the logarithm of the density is returned.

## Details

• Application: Continuous Multivariate

• Density:

p(theta) = exp(-0.5 theta^T Omega^(-1) theta) prod i=1 (1 + exp(theta[i] + alpha[i]))

• Inventor: Zhang et al. (2012)

• Notation 1: theta ~ CRMRF(alpha, Omega)

• Notation 2: p(theta) = CRMRF(theta | alpha, Omega)

• Parameter 1: shape vector alpha

• Parameter 2: positive-definite k x 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.

## Value

`dcrmrf` gives the density and `rcrmrf` generates random deviates.

## References

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.

`dmvn`
 ```1 2 3``` ```library(LaplacesDemon) x <- dcrmrf(rnorm(5), rnorm(5), diag(5)) x <- rcrmrf(10, rnorm(5), diag(5)) ```