N <- 4 # Number of nodes
# Ising parameters:
Graph <- matrix(sample(0:1,N^2,TRUE,prob = c(0.7, 0.3)),N,N) * rnorm(N^2)
Graph <- pmax(Graph,t(Graph)) / N
diag(Graph) <- 0
Thresh <- -(rnorm(N)^2)
Beta <- 1
p1 <- IsingLikelihood(Graph, Thresh, Beta, c(0,1))
a <- 2
b <- -1
# p2 <- IsingLikelihood(Graph/(a^2), Thresh/a - (b*rowSums(Graph))/a^2, Beta, c(-1,1))
p2 <- IsingLikelihood(LinTransform(Graph,Thresh)$graph,
LinTransform(Graph,Thresh)$thresholds ,
Beta, c(-1,1))
LinTransform
round(cbind(p1[,1],p2[,1]),5)
plot(p1[,1],p2[,1])
abline(0,1)
Run the code above in your browser using DataLab