LHS typically requires less samples and converges faster than Monte Carlo Simple Random Sampling (MCSRS) methods when used in uncertainty analysis.
‘output/data/varname’ (‘output/data/z’ for our example). Latin Hypercube Sampling (LHS) is a method of sampling a model input space, usually for obtaining data for training metamodels or for uncertainty analysis. It is placed in the HDF5 output file under It formats the data so that PUQ can easily recognize it in standard output. dump_hdf5() takes three arguments, a name, a value, and an optional description. Line 16 calls dump_hdf5() with our output.
#Latin hypercube sampling script python code
See Making PUQ Work With Your Code and puq/examples/matlab. This is convenient for Python programs (using the optparse module) and C/C++ (using getopt).įor existing test programs, you can easily instruct PUQ to pass parameters in another format. Test programs to take command line parameters in the format –varname=value. Most of the lines are concerned with parsing the command line. It is widely used to generate samples that are known as controlled random samples and is often applied in Monte Carlo analysis because it can dramatically reduce the number of simulations needed to achieve accurate results. y z = 100 * ( y - x ** 2 ) ** 2 + ( 1 - x ) ** 2 dump_hdf5 ( 'z', z ) Latin hypercube sampling is a method that can be used to sample random numbers in which samples are distributed evenly over a sample space. add_option ( "-y", type = float ) ( options, args ) = parser. add_option ( "-x", type = float ) parser. #!/usr/bin/env python import optparse from puqutil import dump_hdf5 usage = "usage: %prog -x x -y y" parser = optparse.