|
require(knitr)
cat(paste0("|<sub>", paste0( c("Actions", "Code Coverage", "Website", "Doxygen", "CRAN Downloads", "CRAN"), collapse="</sub>|<sub>"), "</sub>|\n")) cat(paste0("|", paste0(rep(":---:", 6), collapse="|"), "|\n")) cat(paste0("|", paste0(c("[](https://github.com/bertcarnell/lhs/actions)", "[](https://codecov.io/github/bertcarnell/lhs?branch=master)", "[](https://bertcarnell.github.io/lhs/)", "[](https://bertcarnell.github.io/lhs/html/index.html)", "[](https://cran.r-project.org/package=lhs)", "[](https://cran.r-project.org/package=lhs)"), collapse="|"), "|"))
lhs
provides a number of methods for creating and augmenting
Latin Hypercube Samples and Orthogonal Array Latin Hypercube Samples.
You can install the released version of lhs
from CRAN with:
install.packages("lhs")
You can also install the development version of lhs
from github with:
if (!require(devtools)) install.packages("devtools") devtools::install_github("bertcarnell/lhs")
Create a random LHS with 10 samples and 3 variables:
require(lhs) set.seed(1776) X <- randomLHS(n = 10, k = 3)
Create a design that is more optimal than the random case:
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)
df1 <- data.frame( method = c("random","genetic","maximin","maximin","improved","optimum"), mean_dist = c(mean(dist(X)), mean(dist(X_gen)), mean(dist(X_max1)), mean(dist(X_max2)), mean(dist(X_imp)), mean(dist(X_opt))), min_dist = c(min(dist(X)), min(dist(X_gen)), min(dist(X_max1)), min(dist(X_max2)), min(dist(X_imp)), min(dist(X_opt)))) knitr::kable(df1[order(df1$min_dist, decreasing = TRUE),], col.names = c("Method", "Mean Distance", "Minimum Distance"), digits = 4)
Augment an existing design:
Y <- randomLHS(10, 5) Z <- augmentLHS(Y, 2) dim(Z)
Build an orthogonal array LHS:
# 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) # 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)
R-Help Examples of using the LHS package
StackExchange Examples:
lhs package announcement: R-pkgs New R-Packages: Triangle and LHS
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.