GitPedia

Lhs

Provides a number of methods for creating and augmenting Latin Hypercube Samples and Orthogonal Array Latin Hypercube Samples

From bertcarnell·Updated June 13, 2026·View on GitHub·

`lhs` provides a number of methods for creating and augmenting Latin Hypercube Samples and Orthogonal Array Latin Hypercube Samples. The project is written primarily in C++, distributed under the GNU General Public License v3.0 license, first published in 2018. Key topics include: latin-hypercube, latin-hypercube-sample, latin-hypercube-sampling, lhs, orthogonal-arrays.

Latest release: v1.3.0
<div> <table> <tr> <td> <img align="left" width="200" height="200" src="logo.svg"/> </td> </tr> </table> </div>
<sub>Actions</sub><sub>Code Coverage</sub><sub>Website</sub><sub>Doxygen</sub><sub>CRAN Downloads</sub><sub>CRAN</sub>
R build statusCoverage statusCRAN status
<sub>R-Universe</sub><sub>CRAN Packages</sub><sub>DOI</sub>
name status badgeStatic BadgeStatic Badge

lhs

lhs provides a number of methods for creating and augmenting Latin
Hypercube Samples and Orthogonal Array Latin Hypercube Samples.

Installation

You can install the released version of lhs from
CRAN with:

r
install.packages("lhs")

You can also install the development version of lhs from github with:

r
if (!require(devtools)) install.packages("devtools") devtools::install_github("bertcarnell/lhs")

Quick Start

Create a random LHS with 10 samples and 3 variables:

r
require(lhs)
## Loading required package: lhs
r
set.seed(1776) X <- randomLHS(n = 10, k = 3)

Create a design that is more optimal than the random case:

r
X_gen <- geneticLHS(10, 3, pop = 100, gen = 5, pMut = 0.1) X_max1 <- maximinLHS(10, 3, method = "build", dup = 5) X_max2 <- maximinLHS(10, 3, method = "iterative", optimize.on = "result", eps = 0.01, maxIter = 300) X_imp <- improvedLHS(10, 3, dup = 5) X_opt <- optimumLHS(10, 3, maxSweeps = 10, eps = 0.01)
MethodMean DistanceMinimum Distance
6optimum0.72890.4598
2genetic0.71900.4059
4maximin0.72460.3975
5improved0.70280.3872
3maximin0.72960.3611
1random0.70670.2709

Augment an existing design:

r
Y <- randomLHS(10, 5) Z <- augmentLHS(Y, 2) dim(Z)
## [1] 12  5

Build an orthogonal array LHS:

r
# a 9 row design is returned because a 10 row design is not possible with these algorithms W9 <- create_oalhs(10, 3, bChooseLargerDesign = FALSE, bverbose = FALSE) dim(W9)
## [1] 9 3
r
# a 16 row design is returned because a 10 row design is not possible with these algorithms W16 <- create_oalhs(10, 3, bChooseLargerDesign = TRUE, bverbose = FALSE) dim(W16)
## [1] 16  3

Create a sliced design where each slice is a Latin hypercube and the
union is a Latin hypercube:

r
S <- slicedLHS(m = 4, t = 3, k = 2) dim(S)
## [1] 12  2
r
attr(S, "slices")
##  [1] 1 1 1 1 2 2 2 2 3 3 3 3

Create a nested design where the small design is a subset of the large
design:

r
N <- nestedLHS(small = 4, large = 12, k = 2) dim(N$large)
## [1] 12  2
r
all(N$small == N$large[1:4, ])
## [1] TRUE

Help

R-Help Examples of using the LHS package

StackExchange Examples:

Other

lhs package announcement: R-pkgs New R-Packages: Triangle and
LHS

Contributors

Showing top 2 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from bertcarnell/lhs via the GitHub API.Last fetched: 6/20/2026