In Latin Hypercube sampling, divides each assumption’s probability distribution into nonoverlapping segments, each having equal probability, as illustrated below (Figure 7, Normal Distribution with Latin Hypercube Sampling Segments).
Figure 7. Normal Distribution with Latin Hypercube Sampling Segments
Software has been developed to generate either Latin hypercube or random multivariate samples. The Latin hypercube technique employs a constrained sampling scheme, whereas random sampling corresponds to a simple Monte Carlo technique. The present program replaces the previous Latin. This document is a reference guide for the UNIX Library/Standalone version of the Latin Hypercube Sampling Software. This software.
While a simulation runs, selects a random assumption value for each segment according to the segment’s probability distribution. This collection of values forms the Latin Hypercube sample. After has sampled each segment exactly once, the process repeats until the simulation stops.
The Sample Size option (displayed when you select Run Preferences, then Sample), controls the number of segments in the sample.
Latin Hypercube sampling is generally more precise when calculating simulation statistics than is conventional Monte Carlo sampling, because the entire range of the distribution is sampled more evenly and consistently. Latin Hypercube sampling requires fewer trials to achieve the same level of statistical accuracy as Monte Carlo sampling. The added expense of this method is the extra memory required to track which segments have been sampled while the simulation runs. (Compared to most simulation results, this extra overhead is minor.)
Use Latin Hypercube sampling when you are concerned primarily with the accuracy of the simulation statistics.
MATLAB function to generate an NxP latin hypercube sample with boundsand linear constraints and optional exponential distribution.
Getting the lhsdesigncon
MATLAB function
To use the
lhsdesigncon
function:- Download the zip file from either:
- MATLAB Central File Exchange, or
- GitHub.
- Unzip the files and place them on your MATLAB path(e.g. your
My Documents/MATLAB
folder on Windows). - Use the function (see examplesbelow).
This GitHub repo is adevelopment library. To contribute fork this repo and submit pull requests.
MATLAB Function Description and Examples
Generate an NxP latin hypercube sample with boundsand linear constraints and optional exponential distribution.
X=LHSDESIGNCON(N,P,LB,UB,ISEXP) generates a latin hypercube sample Xcontaining N values on each of P variables. For each column, if ISEXPis FALSE the N values are randomly distributed with one from eachof N intervals, between LB and UB, of identical widths (UB-LB)/N, andthey are randomly permuted. For columns with ISEXP=TRUE, the logarithmof the intervals have identical widths.
X=LHSDESIGNCON(...,A,b) generates a latin hypercube sample subject tothe linear inequalities A*x ? b.
X=LHSDESIGNCON(...,'PARAM1',val1,'PARAM2',val2,...) specifies parametername/value pairs to control the sample generation. See LHSDESIGN forvalid parameters.
Latin hypercube designs are useful when you need a sample that israndom but that is guaranteed to be relatively uniformly/exponentiallydistributed over each dimension.
Example: The following command generates a latin hypercube sample Xcontaining 10000 values for each of 2 variables. The firstvariable is uniformly sampled between -100 and +100, thesecond is exponentially sampled between 10^-1 and 10^2 (ie.the exponent is uniformly sampled between -1 and 2).Additionally, the samples satisfy the constraintsX(1) + X(2) <= 50 and X(2) - X(1) >= 25.
Limitations
- The constraints are not checked for consistency. If they are inconsistentthe function will loop forever, with just a warning 'None of ... samples fit constraints.'
License
The MATLAB Central File Exchange and this source code are distributedunder the BSD-2 License.