Generates a Markov Chain of random fields and returns the sufficient statistics for each of the observations.

This function automatizes the process of generating a random sample of MRFs to be used in Monte-Carlo methods by wrapping rmrf2d and executing it multiple time while storing sufficient statistics instead of the entire lattice.

rmrf2d_mc(
  init_Z,
  mrfi,
  theta,
  family,
  nmc = 100,
  burnin = 100,
  cycles = 4,
  verbose = interactive()
)

Arguments

init_Z

One of two options:

  • A matrix object with the initial field configuration. Its valuesmust be integers in {0,...,C}.

  • A length 2 numeric vector with the lattice dimensions.

mrfi

A mrfi object representing the interaction structure.

theta

A 3-dimensional array describing potentials. Slices represent interacting positions, rows represent pixel values and columns represent neighbor values. As an example: theta[1,3,2] has the potential for the pair of values 0,2 observed in the second relative position of mrfi.

family

The family of parameter restrictions to potentials. Families are: 'onepar', 'oneeach', 'absdif', 'dif' or 'free'. See mrf2d-familiy.

nmc

Number of samples to be stored.

burnin

Number of cycles iterated before start collecting sufficient statistics.

cycles

Number of cycles between collected samples.

verbose

logical indicating whether to print iteration number or not.

Value

A matrix where each row contains the vector of sufficient statistics for an observation.

Note

Fixed regions and incomplete lattices are not supported.

Author

Victor Freguglia

Examples

rmrf2d_mc(c(80, 80), mrfi(1), theta_potts, family = "oneeach", nmc = 8)
#>      [,1] [,2]
#> [1,] 1741 1728
#> [2,] 1736 1749
#> [3,] 1596 1612
#> [4,] 1719 1725
#> [5,] 1771 1715
#> [6,] 1700 1705
#> [7,] 1655 1662
#> [8,] 1731 1721