iorewswitch.blogg.se

Matlab latin hypercube sampling code
Matlab latin hypercube sampling code





  1. MATLAB LATIN HYPERCUBE SAMPLING CODE UPDATE
  2. MATLAB LATIN HYPERCUBE SAMPLING CODE FULL
  3. MATLAB LATIN HYPERCUBE SAMPLING CODE CODE

It takes 0.Conditioned Latin Hypercube Sampling (cLHS) is a type of stratified random sampling that accurately represents the variability of environmental covariates in feature space.

matlab latin hypercube sampling code

MATLAB LATIN HYPERCUBE SAMPLING CODE CODE

The following code shows LHS for 3-D and 10 divisions. Generally, the number of possible LHS is N x ((M-1)!)^(M-1). LHS for 3-D can also be created using the same method(by combining 2-D LHS). And then, combine the 1-D LHS to make 2-D LHS. First, you just make 1-D LHS for regular grid. For example, imagine 3X3 LHS (ie 2-D and 3 divisions).

MATLAB LATIN HYPERCUBE SAMPLING CODE FULL

Please see this answer more as an encouragement than a solution.īy combining 1-D latin hypercube samples (LHS), you can make a full set of LHS for regular grid in higher order dimension. so the desired result seems hardly obtainable. When one plots the generated samples over the number of iterations you get: The problem is: I doubt that it's possible to get all 100 samples in a reasonable time. For most of the points it's fine (1), but as there are 15 missing samples, some points are more distant from others. Where the color indicates the normalized distance to the closest neighbor. Īfter about 10000 iterations one gets the following distribution with 85 of 100 possible placed samples: % if condition checks if there is already a sample in the same row, M = 10 Ĭounter_max = M^(N-1) %=100 maximum number of placeable samples Imagine a cube ( N=3) with M=10 divisions. Because I'm also very interested in a good solution, mine is limited and cannot provide the "100% result". The following example shall illustrate, what the asker could be willing to do and what the result is actually supposed to look like.

matlab latin hypercube sampling code

UPDATE: Example to show limitations of method:

matlab latin hypercube sampling code

(I got 900 samples in 20min when I was testing) You could also implement an interuption code as described here: In MatLab, is it possible to terminate a script, but save all its internal variables to workspace? and see how many samples you got until then. But as you create the resulting matrix just once and use it again and again, don't hesitate to run it 24hrs. I actually would recommend you to use a number of samples as close as possible to the maximum of 1296. You wish 1000 samples, that's a realistic number and can be done in a reasonable time. X is finally containing the coordinates of all your samples.Īs you see I used a while-loop with an underlying if-condition. % the perfect LHC distribution would have 1296 samples for M=6 divisions % For at least 1000 samples M=6 divisions are necessary The following solution is far from fast and elegant, but it's at least a solution.

matlab latin hypercube sampling code

So for this case I still provide my initial idea here: I tried to modify the approach above D = round(bsxfun.), but it won't give you satisfying results. X = lhsdesign(p,N,'criterion','correlation') ĭ = would give you the desired "equal distribution".ĭ then contains the irregular coordinate-distribution for your parameters.įirst I thought you we're looking for samples on a regular grid, which really seems to be a tough task. If not, you could use the built-in function lhsdesign: p = 1000 % Number of points The basic question is whether you want your samples on a regular grid or not.

MATLAB LATIN HYPERCUBE SAMPLING CODE UPDATE

UPDATE #2: solution using built-in function of Statistics Toolbox







Matlab latin hypercube sampling code