library(coda)
source("bench.R")
x <- read.jags()
checkstats <- summary(x)$statistics
if (is.matrix(benchstats)) {
  z <- (benchstats[,1] - checkstats[,1])
  z <- ifelse(z==0, 0, z/benchstats[,2])
} else {
  z <- (benchstats[1] - checkstats[1])
  z <- ifelse(z==0, 0, z/benchstats[2])
}
print(z)
if (any(abs(z) > 0.15)) {
  stop("FAIL")
} else {
  cat("OK\n")
}
