R/sample.R
sampleValues.RdSample n random values from a parameter or a parameter set uniformly.
Dependent parameters whose requirements are not satisfied are represented by a scalar NA in the output.
sampleValues(par, n, discrete.names = FALSE, trafo = FALSE)(integer(1))
Number of values.
(logical(1))
Should names be sampled for discrete parameters or values instead?
Default is code FALSE.
(logical(1))
Transform all parameters by using theirs respective transformation
functions. Default is FALSE.
list. For consistency always a list is returned.
p = makeIntegerParam("x", lower = -10, upper = 10)
sampleValues(p, 4)
#> [[1]]
#> [1] 2
#>
#> [[2]]
#> [1] -9
#>
#> [[3]]
#> [1] 10
#>
#> [[4]]
#> [1] -3
#>
p = makeNumericParam("x", lower = -10, upper = 10)
sampleValues(p, 4)
#> [[1]]
#> [1] -7.536251
#>
#> [[2]]
#> [1] -7.007533
#>
#> [[3]]
#> [1] 0.1185508
#>
#> [[4]]
#> [1] 1.545611
#>
p = makeLogicalParam("x")
sampleValues(p, 4)
#> [[1]]
#> [1] TRUE
#>
#> [[2]]
#> [1] TRUE
#>
#> [[3]]
#> [1] TRUE
#>
#> [[4]]
#> [1] TRUE
#>
ps = makeParamSet(
makeNumericParam("u", lower = 1, upper = 10),
makeIntegerParam("v", lower = 1, upper = 10),
makeDiscreteParam("w", values = 1:2)
)
sampleValues(ps, 2)
#> [[1]]
#> [[1]]$u
#> [1] 2.507692
#>
#> [[1]]$v
#> [1] 6
#>
#> [[1]]$w
#> [1] 2
#>
#>
#> [[2]]
#> [[2]]$u
#> [1] 6.208735
#>
#> [[2]]$v
#> [1] 6
#>
#> [[2]]$w
#> [1] 2
#>
#>