# List of inputs with their distributions and their respective ranges
inputs <- list("r_w" = list(dist = "norm", mean = 0.1, sd = 0.0161812, min = 0.05, max = 0.15),
"r" = list(dist = "lnorm", meanlog = 7.71, sdlog = 1.0056, min = 100, max = 50000),
"T_u" = list(dist = "unif", min = 63070, max = 115600),
"H_u" = list(dist = "unif", min = 990, max = 1110),
"T_l" = list(dist = "unif", min = 63.1, max = 116),
"H_l" = list(dist = "unif", min = 700, max = 820),
"L" = list(dist = "unif", min = 1120, max = 1680),
# for a more nonlinear, nonadditive function, see Morris et al. (1993)
"K_w" = list(dist = "unif", min = 1500, max = 15000))
# Function for Monte Carlo simulation
samples <- function(x, N = 10^5){
switch(x$dist,
"norm" = rnorm(N, x$mean, x$sd),
"lnorm" = rlnorm(N, x$meanlog, x$sdlog),
"unif" = runif(N, x$min, x$max))
}
# Uncertainty distribution of the water flow rate
set.seed(1)
X <- sapply(inputs, samples)
y <- borehole(X)
hist(y, breaks = 50, xlab = expression(paste("Water flow rate ", group("[", m^3/yr, "]"))),
main = "", freq = FALSE)
Run the code above in your browser using DataLab