Generate parameter sets from given ranges, with chosen sampling scheme.
parameterSets(
par.ranges,
samples,
method = c("latin.hypercube", "random", "all.combinations")
)
A named list of (numeric) parameter values. Each element can be:
a single number, for fixed parameters;
a length-2 vector, representing a range of values;
a vector of length >
2, representing a fixed set of values. Also, a length 2 vector can be
defined as a fixed set of values by wrapping it in I()
. Such fixed
sets of values are resampled when method = "latin.hypercube"
or
"random"
.
Number of samples to generate. In the
"all.combinations"
method, the result may not have exactly this
length.
the sampling scheme; see Details.
the result is a data.frame
, with named columns for each
parameter in par.ranges
. Each row represents one parameter set.
Method "latin.hypercube"
generates a regular sequence for each free
parameter range (using quantile
and ppoints
),
and a repeated sequence for each fixed parameter set. Each of these
sequences is then randomly permuted. For the special case of samples =
1
, the mean of each range is returned.
Method "random"
generates uniform random values in each free
parameter range, and random samples from each fixed parameter set.
Method "all.combinations"
generates a regular sequence for each free
parameter range, and keeps each fixed parameter set as given. All
combinations of these values are then calculated (using expand.grid
).
The length of the free parameter sequences is chosen such that the total
number of results does not exceed samples
. However, if fixed
parameter sets are given, the number of combinations of these may exceed
samples
, and then any free parameters will be fixed at their mean
values.
Replicable results can be obtained by using set.seed
.
pars <- list(a = 1, b = 0:1, c = c(1, 10), d = c(-2, -4, -8))
set.seed(10)
hydromad::parameterSets(pars, 10, method = "random")
#> a b c d
#> 1 1 0.5074782 6.864901 -8
#> 2 1 0.3067685 6.109640 -4
#> 3 1 0.4269077 2.021581 -8
#> 4 1 0.6931021 6.363328 -4
#> 5 1 0.0851360 4.222450 -8
#> 6 1 0.2254366 4.859285 -8
#> 7 1 0.2745305 1.467130 -4
#> 8 1 0.2723051 3.377599 -4
#> 9 1 0.6158293 4.589117 -2
#> 10 1 0.4296715 8.525207 -2
hydromad::parameterSets(pars, 10, method = "latin")
#> a b c d
#> 1 1 1.0000000 2 -8
#> 2 1 0.1111111 1 -4
#> 3 1 0.5555556 10 -2
#> 4 1 0.0000000 4 -4
#> 5 1 0.3333333 3 -4
#> 6 1 0.4444444 8 -2
#> 7 1 0.8888889 5 -2
#> 8 1 0.2222222 9 -8
#> 9 1 0.7777778 6 -2
#> 10 1 0.6666667 7 -8
hydromad::parameterSets(pars, 10, method = "all.combinations")
#> a b c d
#> 1 1 0 1 -2
#> 2 1 0 1 -4
#> 3 1 0 1 -8
hydromad::parameterSets(pars, 20, method = "all.combinations")
#> a b c d
#> 1 1 0 1 -2
#> 2 1 1 1 -2
#> 3 1 0 10 -2
#> 4 1 1 10 -2
#> 5 1 0 1 -4
#> 6 1 1 1 -4
#> 7 1 0 10 -4
#> 8 1 1 10 -4
#> 9 1 0 1 -8
#> 10 1 1 1 -8
#> 11 1 0 10 -8
#> 12 1 1 10 -8