
Draw random parameter values from uniform distributions
draw_parameter.RdDraw random values uniformly within specified bounds, supporting both absolute and relative variation types.
Usage
draw_parameter(x, n, type = c("matrix", "list"))Arguments
- x
A numeric/character vector of length 4, or a data frame/matrix where each row defines
c(nominal, min, max, type).- n
Integer scalar, number of random draws to generate.
- type
Character scalar specifying the output format:
"matrix"(default) for annbynrow(x)matrix, or"list"for a list of drawn vectors.
Value
A numeric vector of length n if x is a vector; a numeric matrix
of dimensions n x nrow(x) if x is tabular and type = "matrix"; or a
list of length nrow(x) if type = "list".
Details
When x is a vector, it is treated as a single parameter definition with
components:
x[1]: nominal value (no),x[2]: minimum bound (mi),x[3]: maximum bound (ma),x[4]: variation type (type,"absolute"or"relative").
When type is "relative", the bounds are computed relative to the nominal
value: \(\text{min} = \text{no} \times (1 + \text{mi})\) and
\(\text{max} = \text{no} \times (1 + \text{ma})\). Values are then drawn
uniformly in \([\text{min}, \text{max}]\) using stats::runif().
When x is a matrix or data frame, random draws are performed for each row.
The results can be returned either as a matrix of dimension n x nrow(x) or
as a list of vectors.
Author
Frédéric Grelot, frederic.grelot.1994_cran@m4x.org