Skip to contents

By Hammersley-Clifford a strictly positive distribution factorises over the cliques of its graph exactly when it satisfies the graph's Markov properties, so the graph IS the conditional-independence statement. The partition function and exact marginals are computed by enumeration, which costs states^nodes and is therefore capped – past that the exact answer is unavailable and this says so rather than running for hours.

Usage

morie_esl_markov_rf(edges, psi = NULL, states = 2L)

Arguments

edges

Two-column matrix or list of (i, j) node pairs (1-based), or a symmetric 0/1 adjacency matrix.

psi

Named list mapping "i-j" to a states by states potential; missing edges get an attractive Ising potential.

states

Number of states per node.

Value

List with log_Z, marginals, configurations, probabilities, mode, n_edges.

Details

Potentials are not probabilities: they need not be normalised, need not be below one, and an individual potential has no marginal interpretation. Only the product, after dividing by Z, does.

References

Hammersley, J. M., & Clifford, P. (1971). Markov fields on finite graphs and lattices. Unpublished manuscript.

Examples

r <- morie_esl_markov_rf(rbind(c(1, 2), c(2, 3)))
all(abs(r$marginals - 0.5) < 1e-12)
#> [1] TRUE