gibbs_ising: Gibbs Sampler for Generalized Ising Model

Description Usage Arguments Value Examples

View source: R/ising.R

Description

gibbs_ising is a Gibbs sampler generates data from Ising model, provided starting config and model parameters. It is recommended that user uses a multi-chain approach, that is, providing a matrix u.

Usage

1
gibbs_ising(u, h, J, n_step = 1)

Arguments

u

a binary (-1, 1-valued) vector or matrix. If u is a matrix, each row is taken as an input vector.

h

a vector giving the external field.

J

a symmetric matrix with zero diagonals giving the interaction. If J is NULL, the model degenerates to the case of independent binary.

n_step

the number of Gibbs steps, default = 1

Value

config after Gibbs updates

Examples

1
2
3
4
5
6
n <- 1000
p <- 3
h <- rnorm(p)
J <- matrix(0, p, p)
u <- matrix(2 * (runif(n * p) < 0.5) - 1, n, p)
gibbs_ising(u, h, J)

XiaoqiLu/ziclust documentation built on Dec. 18, 2021, 7:22 p.m.