Learn R Programming

vdg (version 1.1.3)

LHS: Latin Hypercube Sampling

Description

Different versions of latin hypercube sampling (LHS): ordinary LHS, midpoint LHS, symmetric LHS or randomized symmetric LHS. LHS is a method for constructing space-filling designs. They can be more efficient for hypercuboidal design regions than other sampling methods.

Usage

LHS(n, m = 3, lim = c(-1, 1))
MLHS(n, m = 3, lim = c(-1, 1))
SLHS(n, m = 3, lim = c(-1, 1))
RSLHS(n, m = 3, lim = c(-1, 1))

Arguments

n
number of design points to generate
m
number of design factors
lim
limits of the coordinates in all dimensions

Value

Matrix with samples as rows.

Examples

Run this code

set.seed(1234)
pts <- seq(-1, 1, length = 11)

# Ordinary LHS
samp <- LHS(n = 10, m = 2)
plot(samp, main = "LHS")
abline(h = pts, v = pts, col = "lightgrey")

# Midpoint LHS
samp <- MLHS(n = 10, m = 2)
plot(samp, main = "MLHS")
abline(h = pts, v = pts, col = "lightgrey")

# Symmetric LHS
samp <- SLHS(n = 10, m = 2)
plot(samp, main = "SLHS")
abline(h = pts, v = pts, col = "lightgrey")

# Randomized Symmetric LHS
samp <- RSLHS(n = 10, m = 2)
plot(samp, main = "RSLHS")
abline(h = pts, v = pts, col = "lightgrey")

Run the code above in your browser using DataLab