Sallaberry, C., Helton, J., Hora, S.: Extension of Latin hypercube samples with correlated variables. Vořechovský, M., Novák, D.: Correlation control in small-sample Monte Carlo type simulations I: a simulated annealing approach. Vořechovský, M.: Hierarchical refinement of Latin hypercube samples. In: 4th International Workshop on Reliable Engineering Computing (2010) Vořechovský, M.: Extension of sample size in Latin hypercube sampling with correlated variables. Tong, C.: Refinement strategies for stratified sampling methods. In: 46th AIAA/ASME/ASCE/AHS/ASC Structures, Structural Dynamics and Materials Conference, University of Texas at San Antonio (2005) As you can see, half of the fields are empty and will never be chosen as a sample.Pleming, J.B., Manteufel, R.D.: Replicated Latin hypercube sampling. A',B',C',D' denote their respective inverse positions that are then added. In fact there's two possible Latin Hypercubes: and. Consider the 2D example with n=4:Įven_nums = and, hence, A,B,C,D are the 4 possible samples that can be generated with this method. Half of the parameter space will never be chosen as samples. Regarding the symmetrical version, you are indeed only sampling from a subset of the available symmetrical latin hypercubes.
Matlab latin hypercube sampling code#
Once I understood what you wanted to accomplish, your code became a lot more clear to me and I can provide some thoughts. However the core code will generate a Latin hypercube if the last manipulation (multiply by lengths and add param_mins) is omitted. Latin_points = np.concatenate((permutations,inverses), axis=1).TĮdit: I glossed over this, but this code doesn't return Latin hypercubes per se, but rather Latin hypercubes stretched/squeezed and shifted so that the points can be over arbitrary ranges of values.
Inverses = (num_samples - 1) - permutations Return lengths*(latin_points + 0.5)/num_samples + param_minsĭef get_sym_sample(self, param_mins, param_maxes, num_samples): Raise ValueError("Number of samples must be even")ĭef get_lh_sample(self, param_mins, param_maxes, num_samples): I am mostly looking for any insights regarding my algorithms, as while they are very fast even for large dimensions and sample sizes, I don't doubt improvements exist. I am aware that my project structure is probably overkill for the amount of code here. My code can be seen along with specification and performance tests here, although not the visual tests at the moment. Also, the symmetric algorithm doesn't really work properly for odd numbers of samples, so I have outright blocked such samples from being generated. The code can produce either random Latin hypercubes or a rather nongeneral set of symmetric ones (I am convinced my second algorithm cannot in principle generate any possible symmetric Latin hypercube, just a specific type). Statistical tests of higher dimensional cases have convinced me it works successfully there as well. I have tested the code below both using automated tests and by visual inspection of the results for the trivial 2D case. Latin hypercube samples are used for the pre-computation instead of a grid, with the idea that they will more efficiently sample the behavior of the function and result in lower interpolation errors. I pre-generate a list of values for this function at a set of points and use interpolation over the parameters to extend this list to any desired point within a set range. The condensed version of why I want to do this is that I want to evaluate a function which is expensive to compute, and depends on many parameters. For 2D and n=4, this is an example of a symmetric Latin hypercube: | |x| | | , n-1-k), where n is the number of samples. , k), for some integer indices i,j,k, then it also has the sample (n-1-i, n-1-j. One way of expressing this condition, is that (if the samples are zero-indexed) if the hypercube has the sample (i, j. This property essentially means that the hypercube is invariant under spatial inversion. I am also interested in generating a special type of Latin hypercube called a symmetric Latin hypercube. Concatenating these together into a DxN matrix gives a list of coordinates which will form a Latin hypercube. One algorithm for generating this is to generate D random permutations of the integers 0 through N-1, where D is the number of dimensions and N is the desired number of samples. e.g., for 2 dimensions and 4 total samples, this is a Latin hypercube: | | | |x| Latin hypercubes are essentially collections of points on a hypercube that are placed on a cubic/rectangular grid, which possess the property that no two points share any individual coordinate, and every row/column/higher-dimensional-axis is sampled once. I wrote some code to generate Latin hypercube samples for interpolation over high-dimensional parameter spaces.