diff_flipped_hamiltonian_ising: Diff in Energy of Generalized Ising Model by Single Flip

Description Usage Arguments Details Value Examples

View source: R/ising.R

Description

diff_flipped_hamilton_ising is a fast-computation method for energy difference, used in the case where only one variable is flipped.

Usage

1

Arguments

u

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

j

the (column) index of the variable to be flipped over

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.

Details

Δ_j E(u \vert h, J) = H(\tilde{u}; h, J) - H(u; h, J),

where \tilde{u}_j = - u_j and \tilde{u}_{-j} = u_{-j}. It can be shown that Δ_j E(u \vert h, J) = 2 u_j (h_j + J_{j, -j} u_{-j}).

Value

a vector giving the energy difference

Examples

1
2
3
4
5
6
7
h <- c(2, 3)
J <- matrix(c(0, -1, -1, 0), 2, 2)
u <- c(-1, +1)
diff_flipped_hamiltonian_ising(u, 2, h, J)

u <- matrix(c(-1, +1, +1, -1), 2, 2, byrow = TRUE)
diff_flipped_hamiltonian_ising(u, 1, h, J)

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