Sample 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)

Arguments

par

(Param | ParamSet)
Parameter or parameter set.

n

(integer(1))
Number of values.

discrete.names

(logical(1))
Should names be sampled for discrete paramaters or values instead? Default is code FALSE.

trafo

(logical(1))
Transform all parameters by using theirs respective transformation functions. Default is FALSE.

Value

list. For consistency always a list is returned.

Examples

p = makeIntegerParam("x", lower = -10, upper = 10) sampleValues(p, 4)
#> [[1]] #> [1] 4 #> #> [[2]] #> [1] -9 #> #> [[3]] #> [1] 10 #> #> [[4]] #> [1] -7 #>
p = makeNumericParam("x", lower = -10, upper = 10) sampleValues(p, 4)
#> [[1]] #> [1] 0.3711327 #> #> [[2]] #> [1] 6.922401 #> #> [[3]] #> [1] 4.365394 #> #> [[4]] #> [1] -5.17372 #>
p = makeLogicalParam("x") sampleValues(p, 4)
#> [[1]] #> [1] FALSE #> #> [[2]] #> [1] FALSE #> #> [[3]] #> [1] TRUE #> #> [[4]] #> [1] FALSE #>
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] 8.25112 #> #> [[1]]$v #> [1] 9 #> #> [[1]]$w #> [1] 1 #> #> #> [[2]] #> [[2]]$u #> [1] 2.965879 #> #> [[2]]$v #> [1] 5 #> #> [[2]]$w #> [1] 2 #> #>