## Kernel functions shared by the test files. ## Gelman and Meng (1991) bivariate kernel, as used throughout the package ## documentation. With A = 1, B = 0, C1 = C2 = 3 the target has mean ## (1.459, 1.459); see Ardia, Hoogerheide and van Dijk (2009, JSS 29(3)). GelmanMeng <- function(x, A = 1, B = 0, C1 = 3, C2 = 3, log = TRUE) { if (is.vector(x)) x <- matrix(x, nrow = 1) r <- -.5 * (A * x[,1]^2 * x[,2]^2 + x[,1]^2 + x[,2]^2 - 2 * B * x[,1] * x[,2] - 2 * C1 * x[,1] - 2 * C2 * x[,2]) if (!log) r <- exp(r) as.vector(r) } ## Univariate Gaussian kernel with mean 'm' and variance 1 (unnormalised). Gauss1d <- function(x, m = 2, log = TRUE) { x <- as.matrix(x) r <- -0.5 * (x[,1] - m)^2 if (!log) r <- exp(r) as.vector(r) }