Latin Hypercube Sampling (LHS)

Sandia's Latin Hypercube Sampling package predates Dakota, though is no longer distributed as a standalone package.  LHS is distributed with Dakota and can be used as a distinct standalone capability.

Authors: G. D. Wyss, L .P. Swiler, S. L. Brown, M. S. Eldred, S. Daniel (with earlier contributions by R. L. Iman and M.J. Shortencarier)

License: GNU LGPL v2.1 or later

Download: See Dakota Downloads for binary or source packages. Once the package is unpacked, the lhsdrv or lhsdrv.exe binary is included in dakota/bin/.  The LHS Fortran source code is included in packages/external/LHS.

References:

Guidance

Place the following files in the directory from which you run lhsdrv.exe;

  • Initialization file SIPRA.INI (example included in LHS source package)
  • Input file, e.g., unif.dat (example below) which is a simple example which generates 60 samples from four uniform random variables on the interval -1 to 1, or KEYWORD.DAT (which is included in the LHS source package), which is a more comprehensive example of possible random variable types and syntax.  The LHS manual referenced above explains the format of the input file in more detail.

Then open a terminal or command prompt, change directory to the input files and run lhsdrv, e.g.:

  • C:\lhs\bin\lhsdrv.exe unif.dat
  • /home/user/lhs/bin/lhsdrv unif.dat

LHS will generate the samples.   For example, the unif.dat input will generate 60 observations (samples) from 4 uniform distributions between -1 and 1, with a seed 1342.  The output will go to the file 1.out, any messages will go to 2.out.  Note also that there are several fortran files generated, and the one that is most useful is fort.4.  The file 1.OUT has the samples, but the file fort.4 has everything you specify in the line “lhsrpts” (reports).  In this case, we are specifying everything (the data, the correlations, and histograms of the samples) so all of that is printed in fort.4.  Finally, you can change the names of things like the output file (from 1.out to myfile.out or myfile.dat or anything you want) and also the distribution names.

 

Example input file unif.dat

lhstitl TEST #34Ran2SA
lhsout 1.out
lhsmsg 2.out
lhsseed 1342
lhsobs 60 
lhsrpts data corr hist
dataset:
dist1 uniform -1. 1.
dist2 uniform -1. 1.
dist3 uniform -1. 1.
dist4 uniform -1. 1.