Description Usage Arguments Value Author(s) Examples
View source: R/simulate_multi_km.R
Performs conditional or non-conditional simulations in n different batches of p points.
1 2 3 |
object |
The current kriging model. km object. |
nsim |
Integer. Number of Gaussian process simulation to perform for each batch of p points. |
nbatch |
Integer. The number n of batches. |
seed |
The random seed. For repeatability. |
newdata |
Matrix of dimension (n*p) x d containing the n different batches of p points where the simulations are performed. The number of rows must be a multiple of n. |
cond |
Boolean. When set to TRUE, the simulations are conditional simulations. |
nugget.sim |
An optimal additional nugget to the simulations. |
checkNames |
Boolean. See the documentation of the |
type |
See the documentation of the |
pn.only |
Boolean. When set to TRUE, only the conditional simulations are returned, and other auxiliary results are not returned. |
A list with the following fields. (i) allsimu: (n*p) x nsim matrix. The first p rows correspond to the nsim simulations (each simulation being a column) associated to batch 1. Next p rows are for batch 2 and so on. (ii) allKn.inv: (n*p) x p matrix containing n different p x p matrices. Matrix number i is the inverse of the p x p non-conditional covariance matrix of the p simulation points associated to the batch i. (iii) allmn: n*p array with the kriging means of all n*p points stored in newdata.
Clement Chevalier clement.chevalier@unine.ch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | library(KrigInv)
library(randtoolbox)
myfun <- branin_robinv
d <- 3
set.seed(8)
n0 <- 30
T <- 10
opt.index <- c(3)
inv.index <- c(1,2)
lower <- rep(0,times=d)
upper <- rep(1,times=d)
d.inv <- length(inv.index);d.opt <- length(opt.index)
lower.inv <- lower[inv.index];upper.inv <- upper[inv.index]
lower.opt <- lower[opt.index];upper.opt <- upper[opt.index]
design <- matrix(runif(d*n0),nrow=n0)
response <- myfun(design)
model <- km(formula = ~1,design = design,response = response,covtype = "matern3_2")
p <- n.optpoints <- 40
nsimu <- 1000
n <- n.points <- 50 # number of integration points
inv.integration.points <- t(lower.inv + t(sobol(n=n.points,dim=d.inv))*(upper.inv-lower.inv))
opt.simulation.points <- t(lower.opt + t(sobol(n=n.optpoints,dim=d.opt))*(upper.opt-lower.opt))
allsimupoints <- matrix(c(0) , nrow=(n*p) , ncol = d)
for(i in 1:n){
# deal with integration point i
index.first <- 1+(i-1)*p
index.last <- i*p
inv.point <- inv.integration.points[i,]
simu_points <- matrix(c(0),nrow=p,ncol=d)
for(alpha in 1:length(opt.index)) simu_points[,opt.index[alpha]] <- opt.simulation.points[,alpha]
for(alpha in 1:length(inv.index)) simu_points[,inv.index[alpha]] <- as.numeric(inv.point[alpha])
allsimupoints[index.first:index.last ,] <- simu_points
}
## Not run:
result <- simulate_multi_km(object=model,nsim=nsimu,nbatch = n, newdata=allsimupoints,
cond=TRUE,checkNames=FALSE,type="UK",seed=NULL,
pn.only=FALSE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.