MrUrq / LatinHypercubeSampling.jl

Julia package for the creation of optimised Latin Hypercube Sampling Plans

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specify inclusive or not for the bounds on scaleLHC

DomDF opened this issue · comments

Hi,
I was wondering if there was a way to ask that the bounds when rescaling a LHC sampler could not be included?
Is there an argument in the function that I am not aware of?

At the moment, I am having to use the below code to add 2 extra samples, which I then use to filter our the values at the bounds:

function draw_lhs(dist, n::Int)
    samples = randomLHC(n + 2, 1) |>    # Add 2 dummy samples
        x -> scaleLHC(x, [(0, 1)])[:, 1] |>    # rescale LHC using bounds that I would like not to be included in the sampling
        x -> filter(∉((0, 1)), x) |>    # Remove 2 samples corresponding to the bounds (Pr = 0 and Pr  = 1)
        x -> sort(x) |>
        x -> quantile(dist, x)
    return samples
end

Kind Regards,
Dom

Hi,
This is not possible currently. Either you can specify the bounds the be narrower and so that they coincide with your centers or create a range which is n+2 and then discard the edges.

LHC = randomLHC(n, 1)
vals=range(start=0,stop=1,length=n+2)
vals[LHC[:,1].+1] |> sort

9-element Vector{Float64}:
 0.1
 0.2
 0.3
 0.4
 0.5
 0.6
 0.7
 0.8
 0.9