[R] Latin Hypercube Sampling with a condition
Rob Carnell
carnellr at battelle.org
Thu Jun 2 14:30:10 CEST 2011
Duarte Viana <viana.sptd <at> gmail.com> writes:
>
> Hello all,
>
> I am trying to do a Latin Hypercube Sampling (LHS) to a 5-parameter
> design matrix. I start as follows:
>
> library(lhs)
>
> p1<-randomLHS(1000, 5)
>
> If I check the distribution of each parameter (column), they are
> perfectly uniformly distributed (as expected).For example,
>
> hist(p1[,1])
>
> Now the hard (maybe strange) question. I want the combination of the
> first three parameters to sum up to 1 (which obviously do not)
>
> s<-p1[,1]+p1[,2]+p1[,3]
>
> s==1
>
> It occurred to me to divide each of these parameters with the sum
> (vector "s" above). However the uniform distribution is lost (example
> for parameter 1 - first column):
>
> par1.transf<-p1[,1]/s
>
> hist(par1.transf)
>
> So, is there a way to maintain the random LHS (with uniformly
> distributed parameters) so that the refered condition is fulfilled?
>
> Any suggestions would be much welcome.
>
> Thanks,
>
> Duarte
>
>
Duarte,
In my experience with Latin hypercube samples, most people draw the sample on
a uniform hypercube and then transform the uniform cube to have new
distributions on the margins. The transformed distributions are not
necessarily uniform. It is possible to draw a Latin hypercube with correlated
margins and I hope to add that to my package in the future. I have also done
transforms such that the transformed marginal distributions are correlated (as
you have in your example). I have not seen a correlated set of uniform
marginal distributions such that the margins sum to one, however. I'll make a
quick example argument that explains the difficulty...
In two dimensions, you could draw this which is uniform and correlated.
x <- seq(0.05, 0.95, length=10)
y <- 1-x
all.equal(x+y, rep(1, length(x)))
hist(x)
hist(y)
But in three dimensions, it is hard to maintain uniformity because large
samples on the first uniform margin overweight the small samples on the other
margins.
x <- seq(0.05, 0.95, length=10)
y <- runif(length(x), 0, 1-x)
z <- 1-x-y
hist(x)
hist(y)
hist(z)
If you could explain why you want to maintain the uniformity on the margins, I
might be able to suggest something different.
Rob
More information about the R-help
mailing list