#Try Naive Monte Carlo on a given function with different failure level
#Limit state function defined by Kiureghian & Dakessian :
kiureghian = function(x, b=5, kappa=0.5, e=0.1) {b - x[2] - kappa*(x[1]-e)^2}
res = list()
res[[1]] = MonteCarlo(2,kiureghian,failure = 0,plot=TRUE)
res[[2]] = MonteCarlo(2,kiureghian,failure = 1,plot=TRUE)
res[[3]] = MonteCarlo(2,kiureghian,failure = -1,plot=TRUE)
#Try Naive Monte Carlo on a given function and change number of points.
#Limit state function defined by Waarts :
waarts = function(u) { min(
(3+(u[1]-u[2])^2/10 - (u[1]+u[2])/sqrt(2)),
(3+(u[1]-u[2])^2/10 + (u[1]+u[2])/sqrt(2)),
u[1]-u[2]+7/sqrt(2),
u[2]-u[1]+7/sqrt(2))
}
res = list()
res[[1]] = MonteCarlo(2,waarts,N_max = 10000)
res[[2]] = MonteCarlo(2,waarts,N_max = 100000)
res[[3]] = MonteCarlo(2,waarts,N_max = 500000)Run the code above in your browser using DataLab