#Try Subset Simulation Monte Carlo on a given function and change number of points.
if (FALSE) {
res = list()
res[[1]] = SubsetSimulation(2,kiureghian,N=10000)
res[[2]] = SubsetSimulation(2,kiureghian,N=100000)
res[[3]] = SubsetSimulation(2,kiureghian,N=500000)
}
# Compare SubsetSimulation with MP
if (FALSE) {
p <- res[[3]]$p # get a reference value for p
p_0 <- 0.1 # the default value recommended by Au and Beck
N_mp <- 100
# to get approxumately the same number of calls to the lsf
N_ss <- ceiling(N_mp*log(p)/log(p_0))
comp <- replicate(50, {
ss <- SubsetSimulation(2, kiureghian, N = N_ss)
mp <- MP(2, kiureghian, N = N_mp, q = 0)
comp <- c(ss$p, mp$p, ss$Ncall, mp$Ncall)
names(comp) = rep(c("SS", "MP"), 2)
comp
})
boxplot(t(comp[1:2,])) # check accuracy
sd.comp <- apply(comp,1,sd)
print(sd.comp[1]/sd.comp[2]) # variance increase in SubsetSimulation compared to MP
colMeans(t(comp[3:4,])) # check similar number of calls
}
Run the code above in your browser using DataLab