Different behaviors on Latin Hypercube Sampling from two packages

I tried QuasiMonteCarlo.jl and LatinHypercubeSampling.jl.

#for QuasiMonteCarlo.jl
s1 = QuasiMonteCarlo.sample(25, [0.0,0.0], [1.0,1.0], LatinHypercubeSample())

2×25 Matrix{Float64}:
0.4 0.56 0.96 1.0 0.68 0.16 … 0.48 0.52 0.28 0.32 0.84 0.24
0.16 0.28 0.96 0.68 1.0 0.08 0.76 0.36 0.6 0.04 0.2 0.92

#for LatinHypercubeSampling.jl
s2 = scaleLHC(randomLHC(25,2),[(0.0,1.0),(0.0,1.0)])’

2×25 adjoint(::Matrix{Float64}) with eltype Float64:
0.583333 0.791667 0.708333 0.666667 … 0.208333 0.916667 1.0
0.0416667 1.0 0.333333 0.0833333 0.5 0.208333 0.458333

The results from QuasiMonteCarlo.jl are evenly distributed at the edges of 25 evenly spaced regions in [0, 1] for both dimensions. The results from LatinHypercubeSampling.jl seem to be randomly located in the 25 evenly spaced regions in [0, 1].

Any idea how to use QuasiMonteCarlo.jl to get results similar to that of LatinHypercubeSampling.jl?

Interesting, since it’s just using LatinHypercubeSampling.jl to do the sampling. Open an issue.

The cause was found. Two packages handle the boundaries of a closed region differently. For a N-sample case from a region [a,b], QuasiMonteCarlo.jl divides the region [a,b] into N subregions with N+1 edges at (a, a+(b-a)/(N), a+(b-a)/(N)*2, a+(b-a)/(N)*3, …, b), but the package ignores the very left edge [a] during sampling. LatinHypercubeSampling.jl divides the region [a,b] into N-1 subregions with N edges at (a, a+(b-a)/(N-1), a+(b-a)/(N-1)*2, a+(b-a)/(N-1)*3, …, b) and uses all edges for sampling. Both packages only choose samples from these edges, their behaviors are different from R package “lhs”, which draws samples not only at the edges of subregions, but also in the subregions.

The two packages would show same behavior if one chooses the left boundary for LatinHypercubeSampling.jl considering the above difference. It can be demonstrated in the following simplified one-dimensional case:

s1 = QuasiMonteCarlo.sample(25, [0.0], [1.0], LatinHypercubeSample())
sort(s1[1,:])’
s2 = scaleLHC(randomLHC(25,1), [(0.04,1.0)])’
sort(s2[1,:])’

2 Likes

Is this on master? There’s a lot of changes on the current master in comparison to the release version.

No. I used QuasiMonteCarlo v0.2.19 and LatinHypercubeSampling v1.8.0

Yeah try current master and see if that helps.

For the master of QuasiMonteCarlo.jl, sampled points locate at the centers of subregions now.
For the master of LatinHypercubeSampling.jl, sampled points still locate at the edges of subregions.

Interesting, can you open an issue?

Yea.