# NOT RUN {
mu1 <- c(-1, -1)
mu2 <- c(+1, +1)
sigma.sq <- 0.1225
X <- matrix(c(-2,-1,0,-2,0,2,0,1,2, -2,-1,-2,0,0,0,2,1,2), ncol = 2)
f <- function(x) {
px <- 1/4/pi/sqrt(sigma.sq) * exp(-1/2/sigma.sq *
sum((x - mu1)^2)) + 1/4/pi/sqrt(sigma.sq) *
exp(-1/2/sigma.sq * sum((x - mu2)^2))
return(log(px))
}
y <- rep(NA, 9)
for(i in 1:9) y[i] <- f(X[i,])
Ef <- GProcess(X, y, request.functions = TRUE)$Ef
Ey <- NA*y
for(i in 1:9) Ey[i] <- Ef(X[i,])
data.frame(X, y, Ey)
## Gaussian process close to exact at points supplied.
# }
Run the code above in your browser using DataLab