Hi,

I'd like to use Latin Hypercube Sampling (LHC) in the the context of
uncertainty / sensitivity analysis of a complex model with approximately 10
input variables. With the LHC approach I'd like to generate parameter
combinations for my model input variables.
Therefore I came across an simple example here on the mailing list (
https://stat.ethz.ch/pipermail/r-help/2011-June/279931.html):

Easy Example
Parameter 1: normal(1, 2)
Parameter 2: normal(3, 4)
Parameter 3: uniform(5, 10)

require(lhs)
N <- 1000
x <- randomLHS(N, 3)
y <- x
y[,1] <- qnorm(x[,1], 1, 2)
y[,2] <- qnorm(x[,2], 3, 4)
y[,3] <- qunif(x[,3], 5, 10)

par(mfrow=c(2,2))
apply(x, 2, hist)

par(mfrow=c(2,2))
apply(y, 2, hist)


However, some of my parameters are uniformly distributed integer values
and/or uniformly distributed classes. So, for example one input parameter
can be "yellow", "green", "red" with equal probability. Of course these
attributes can be transformed into integers (1,2,3) with a uniform
distribution.

So far I've tried to use the round function:

y[,3] <- round(qunif(x[,3], 5, 10))

which does not sample the 1 and 10 eqally to 2:8 (this is discussed already
somewhere else here on the list in another context, and the function
sample() is suggested). How can this be applied here and how can a column
of the lhs-output be transformed in e.g integers 1:10 or the three colors
as mentioned above?

thanks,

Johannes

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to