Procedure: Generate a Latin hypercube

Description and Background

A Latin hypercube (LHC) is a random set of points in \([0,1]^p\) constructed so that for \(i=1,2,\ldots,p\) the i-th coordinates of the points are spread evenly along [0,1].

Inputs

  • Number of dimensions \(p\)
  • Number of points desired \(n\)

Outputs

  • LHC \(D = \{x_1, x_2, \ldots, x_n\}\)

Procedure

  1. For each \(i=1,2,\ldots,p\), independently generate \(n\) random numbers \(u_{i1}, u_{i2}, \ldots, u_{in}\) in [0,1] and a random permutation \(b_{i1}, b_{i2}, \ldots, b_{in}\) of the integers \(0,1,\ldots,n-1\).
  2. For each \(i=1,2,\ldots,p\) and \(j=1,2,\ldots,n\) let \(x_{ij} = (b_{ij}+u_{ij})/n\).
  3. For \(j=1,2,\ldots,n\), the j-th LHC point is \(x_j = (x_{1j}, x_{2j}, \ldots, x_{pj})\).

Additional Comments

The construction of a LHC implies that the projection of the set of points into the i-th dimension results in \(n\) points that are evenly spread over that dimension. If we project into two or more of the \(p\) dimensions, a LHC may also appear to be well spread (space-filling) in that projection, but this is not guaranteed.