[R] Latin hypercube sampling from a non-uniform distribution

Marine Regis
Mon, 07 Aug 2017 21:51:32 -0000

Thanks for your answer.


However, my variable is simulated from the cumulative distribution function of
the Poisson distribution. So, the pattern obtained from the function
"qpois" is not the same as the observed pattern (i.e., obtained from
the function "ppois")

set.seed(5)
mortality_probability <- round(ppois(seq(0, 7, by = 1), lambda = 0.9), 2)
barplot(mortality_probability, names.arg = seq(0, 7, by = 1), xlab = "Age
class", ylab = "Probability")

library(lhs)
set.seed(1)
parm <- c("var1", "var2",
"mortality_probability")
X <- randomLHS(100, length(parm))
colnames(X) <- c("var1", "var2",
"mortality_probability")
X[, "mortality_probability"] <- qpois(X[,
"mortality_probability"], 0.9)
hist(X[, "mortality_probability"])


Thanks for your time

Marine




________________________________
De : S Ellison <S.Ellison at LGCGroup.com>
Envoy? : lundi 7 ao?t 2017 14:36
? : Marine Regis; r-help at r-project.org
Objet : RE: Latin hypercube sampling from a non-uniform distribution

> How can I draw a Hypercube sample for the variable  mortality_probability
so
> that this variable exhibits the same pattern as the observed distribution?

One simple way is to use the uniform random output of randomLHS as input to the
quantile function for your desired distribution(s).

For example:

q <- randomLHS(1000, 3)
colnames(q) <- c("A", "B", "mort")
q[, "mort"] <- qpois(q[,"mort"], 1.5)


S Ellison






*******************************************************************
This email and any attachments are confidential. Any use...{{dropped:11}}