MrUrq / LatinHypercubeSampling.jl

Julia package for the creation of optimised Latin Hypercube Sampling Plans

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Evenly distributed samples?

melodyjulia opened this issue · comments

Please try the following case:

s1 = scaleLHC(randomLHC(25,1), [(0.00,1.0)])
s2 = scaleLHC(randomLHC(25,1), [(0.00,1.0)])
s3 = scaleLHC(randomLHC(25,1), [(0.00,1.0)])
s4 = scaleLHC(randomLHC(25,1), [(0.00,1.0)])

@show sort(s1[:,1])
@show sort(s2[:,1])
@show sort(s3[:,1])
@show sort(s4[:,1])

Output:
sort(s1[:, 1]) = [0.0, 0.041666666666666664, 0.08333333333333333, 0.125, 0.16666666666666666, 0.20833333333333334, 0.25, 0.2916666666666667, 0.3333333333333333, 0.375, 0.4166666666666667, 0.4583333333333333, 0.5, 0.5416666666666666, 0.5833333333333334, 0.625, 0.6666666666666666, 0.7083333333333334, 0.75, 0.7916666666666666, 0.8333333333333334, 0.875, 0.9166666666666666, 0.9583333333333334, 1.0]
sort(s2[:, 1]) = [0.0, 0.041666666666666664, 0.08333333333333333, 0.125, 0.16666666666666666, 0.20833333333333334, 0.25, 0.2916666666666667, 0.3333333333333333, 0.375, 0.4166666666666667, 0.4583333333333333, 0.5, 0.5416666666666666, 0.5833333333333334, 0.625, 0.6666666666666666, 0.7083333333333334, 0.75, 0.7916666666666666, 0.8333333333333334, 0.875, 0.9166666666666666, 0.9583333333333334, 1.0]
sort(s3[:, 1]) = [0.0, 0.041666666666666664, 0.08333333333333333, 0.125, 0.16666666666666666, 0.20833333333333334, 0.25, 0.2916666666666667, 0.3333333333333333, 0.375, 0.4166666666666667, 0.4583333333333333, 0.5, 0.5416666666666666, 0.5833333333333334, 0.625, 0.6666666666666666, 0.7083333333333334, 0.75, 0.7916666666666666, 0.8333333333333334, 0.875, 0.9166666666666666, 0.9583333333333334, 1.0]
sort(s4[:, 1]) = [0.0, 0.041666666666666664, 0.08333333333333333, 0.125, 0.16666666666666666, 0.20833333333333334, 0.25, 0.2916666666666667, 0.3333333333333333, 0.375, 0.4166666666666667, 0.4583333333333333, 0.5, 0.5416666666666666, 0.5833333333333334, 0.625, 0.6666666666666666, 0.7083333333333334, 0.75, 0.7916666666666666, 0.8333333333333334, 0.875, 0.9166666666666666, 0.9583333333333334, 1.0]

All samples (25) are located at the edges of (24) evenly divided subregions: such as [0,1/24], [1/24, 2/24], ...., [23/24, 1.0].
Meanwhile, the results from four times sampling are same except their orders before sorting.

This is because it is a 1D sampling plan. The points can only be in evenly distributed bins. The LHC is really only useful for dimensions larger than 1.

Even for multi-dimensional situation, the samples are still located at the edges of evenly distributed bins for each dimension. It means any sample is located at one facet of a hypercube, not in a hypercube.

Scaling places the maximum and minimum on the edges. If you want to you can always move the edges to coincide with the center for your range. Alternatively use a range that is n+2 and use the indices+1 to get the centers