basworks.blogg.se

Matlab latin hypercube sampling
Matlab latin hypercube sampling













matlab latin hypercube sampling

% 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. X is finally containing the coordinates of all your samples.Īs you see I used a while-loop with an underlying if-condition.

matlab latin hypercube sampling

You wish 1000 samples, that's a realistic number and can be done in a reasonable time. I actually would recommend you to use a number of samples as close as possible to the maximum of 1296. But as you create the resulting matrix just once and use it again and again, don't hesitate to run it 24hrs. (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. UPDATE: Example to show limitations of method: The following example shall illustrate, what the asker could be willing to do and what the result is actually supposed to look like. Because I'm also very interested in a good solution, mine is limited and cannot provide the "100% result". Ī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. Where the color indicates the normalized distance to the closest neighbor. For most of the points it's fine (1), but as there are 15 missing samples, some points are more distant from others. 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. so the desired result seems hardly obtainable. 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. MATLAB LATIN HYPERCUBE SAMPLING CODE FULL For example, imagine 3X3 LHS (ie 2-D and 3 divisions). First, you just make 1-D LHS for regular grid. And then, combine the 1-D LHS to make 2-D LHS.

matlab latin hypercube sampling

LHS for 3-D can also be created using the same method(by combining 2-D LHS). Generally, the number of possible LHS is N x ((M-1)!)^(M-1). The following code shows LHS for 3-D and 10 divisions. 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 CODE.
  • MATLAB LATIN HYPERCUBE SAMPLING CODE FULL.
  • MATLAB LATIN HYPERCUBE SAMPLING CODE UPDATE.














  • Matlab latin hypercube sampling