rescuenas.blogg.se

Latin hypercube sampling script
Latin hypercube sampling script










  1. Latin hypercube sampling script full#
  2. Latin hypercube sampling script software#
  3. Latin hypercube sampling script code#
  4. Latin hypercube sampling script free#

Print("\n\tPython script for generating Latin Hypercube samples") each variableī = np.zeros((a.shape,a.shape),dtype=float) # For each sample, get the nearest neighbor w.r.t. If sampleMin > ratio*minRadius and sampleMinNorm > ratio*minRadius: Print(sampleMin,sampleMinNorm,ratio*minRadius) RandStandardNorm = np.genfromtxt('ntemp.csv',delimiter=',',usecols=cols) RandUniform = np.genfromtxt('utemp.csv',delimiter=',',usecols=cols) RandStandardNorm = CDFtoNorm(randUniform) RandUniform = convertToRandomCDF(dim,history,h) Print("Sampling Latin-Hypercube array space (%s)" %(sampleNum)) Point,history,eIndices = getDraw(dim,eIndices,maxIndex,history) H,maxIndex = initializeSpace(dim,numStrata) # In 3 tries, get another LH sample and go again # Try getting different random points in the array space RandCDFVal = float(np.random.uniform(leftEdge,0.999999*rightEdge,1)) LeftEdge, rightEdge = indexToEdge(dim,leftEdge,h) #iterate over leftEdge, convert ints to floats #iterate over each index, compare to history Point,eIndex = getLimitedDraw(dim,eIndex,history) # Limited draw by limiting sample-able indices Indices = if x != ent]ĭef getDraw(dim,eligibleIndices,maxIndex,history): # set eligible indices for each dimension

Latin hypercube sampling script software#

WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISINGįROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE ORĭef getIndex(val,h,minVal=0.0,maxVal=1.0):ĭef indexToEdge(dim,lEdge,h,minVal=0.0,maxVal=1.0):ĭef getFloatVal(index,h,minVal=0.0,maxVal=1.0):ĭef initializeSpace(dim,numStrata,minVal=0.0,maxVal=1.0,debug='False'):ĭef getLimitedDraw(dim,eligibleIndices,history): HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,ĮXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES Included in all copies or substantial portions of the Software. The above copyright notice and this permission notice shall be Software is furnished to do so, subject to the following Sell copies of the Software, and to permit persons to whom the Restriction, including without limitation the rights to use,Ĭopy, modify, merge, publish, distribute, sublicense, and/or Obtaining a copy of this software and associated documentationįiles (the "Software"), to deal in the Software without

Latin hypercube sampling script free#

Permission is hereby granted, free of charge, to any person # Array space is filled using strata index exclusion # Once array space is filled, a random value is generated within each cell # Parameter space is mapped to an array index space using integer truncation # Script for generating standard uniform/standard normal Latin-Hypercube samples Where "x" is the parameter value, is the parameter standard deviation, is the parameter mean value, and is the standard normal value. Where "x" is the parameter value, is the parameter minimum, is the parameter maximum, and is the standard uniform value.Ĭonverting LHS output from Standard Normal to Parameter Space _ Each random sample can be converted to parameter values via the following equations:Ĭonverting LHS output from Standard Uniform to Parameter Space _

Latin hypercube sampling script code#

This code outputs samples for the standard uniform and standard normal distributions. Posterior Distribution – the resulting statistical distribution of the model outputĪn example implementation of a LHS algorithm is below. Prior Distribution – the statistical distribution of the input parameters to a model Due to the possibility of clustering (LHS sample with points close together) of sample points, a nearest neighbour restriction can be imposed. This is best visualized in a 2D space with the following figure:Īs seen in Figure 1, there is only one sample in each row and column in (X,Y) space. Once a suitable CDF sample is made, the sample CDF value is inversely mapped back to a parameter value.Ī requirement for LHS is that each region of the CDF can only be sampled once for each parameter.

Latin hypercube sampling script full#

By representing each variable as its Cumulative Distribution Function (CDF) (prior distribution) and partitioning the CDF into N regions and taking a single sample from each region, this increases the likelihood that the full range of the posterior distribution is sampled. LHS typically requires less samples and converges faster than Monte Carlo Simple Random Sampling (MCSRS) methods when used in uncertainty analysis. Latin Hypercube Sampling (LHS) is a method of sampling a model input space, usually for obtaining data for training metamodels or for uncertainty analysis. 3.2 Converting LHS output from Standard Normal to Parameter Space.3.1 Converting LHS output from Standard Uniform to Parameter Space.












Latin hypercube sampling script