Latin hypercube sampling r example
Sim_stat % left_join(., q_obs, by = "date") %>% rename( q_obs = discharge) %>% gather( key = "variable", value = "q", -date, -q_min, - q_max, -period) Val_stat % get_run_stat(., run_best) %>% mutate_if(., is.numeric, ~ (. before = 1)Ĭal_stat % select( !! names(q_val $simulation $q_sim)) %>% get_run_stat(., run_best) %>% mutate_if(., is.numeric, ~ (. Run_best % select( -date) %>% mutate( q_max = pmap_dbl(., max),
Latin hypercube sampling r example series#
The hydroGOF package (Mauricio Zambrano-Bigiarini, 2017) summarizes frequently used functions for the evaluation of time series of hydrological variables. To evaluate simulated time series of hydrological variables, multiple goodness-of-fit functions are available from literature. In this example we will implement LHS sampling. Other ‘pseudo’ and ‘quasi’ random numbers (that can be relevant for some methods for sensitivity analysis) can be drawn using the package randtoolbox (Dutang C. You can draw Latin Hypercube Samples with the package lhs (Carnell, 2019). The simplest approach might be to use the function runif() from the base R package stats (R Core Team, 2019) to draw uniform samples for each parameter. For R different routines are available to draw random samples. A common procedure in hydrological modeling is to draw random samples for a set of parameters, to execute the model with all drawn parameter combinations, evaluate the simulations based on one or several criteria, and select parameter sets that were able to reproduce the observation date sufficiently with the applied model setup.