SkillAgentSearch skills...

Lhslib

Latin hypercube sampling code for the lhs pacakge in the statistical software package R (www.r-project.org)

Install / Use

/learn @bertcarnell/Lhslib
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

lhslib

C++ Latin hypercube sampling code. Used in the lhs pacakge in the R statistical software (www.r-project.org).
Link to the lhs project page here.

|<sub>Linux & MacOS</sub>|<sub>Windows</sub>|<sub>Code Coverage</sub>|<sub>Actions</sub>|<sub>CodeQL</sub>|<sub>Linter</sub>| |:---:|:---:|:---:|:---:|:---:|:---:| |Build Status|Build status|codecov|CMake|CodeQL|CppLinter|

Connections to Other Projects

Documentation

The API is primarily documented through the Doxygen documentation supplied here.

Examples

The following code illustrates how the API is called from C++. The bclib::matrix<T> class is a simple matrix class that only includes necessary operations (bclib). More robust matrix templates could be used in the future. lhslib is the namespace of this project.

randomLHS Algorithm

int n = 4;
int k = 3;
bool bPreserveDraw = false;
bclib::matrix<double> result = bclib::matrix<double>(n,k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::randomLHS(n, k, bPreserveDraw, result, oRandom);

improvedLHS Algorithm

int n = 4;
int k = 3;
int dup = 5;
bclib::matrix<int> result = bclib::matrix<int>(n,k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::improvedLHS(n, k, dup, result, oRandom);

maximinLHS Algorithm

int n = 4;
int k = 3;
int dup = 5;
bclib::matrix<int> result = bclib::matrix<int>(n, k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::maximinLHS(n, k, dup, result, oRandom);

optimumLHS Algorithm

int n = 4;
int k = 3;
int maxSweeps = 2;
double eps = 0.1;
int jLen = 7; // (4 choose 2) + 1
bclib::matrix<int> result = bclib::matrix<int>(n, k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::optimumLHS(n, k, maxSweeps, eps, result, jLen, oRandom, false);

geneticLHS Algorithm

int n = 10;
int k = 4;
int pop = 20;
int gen = 5;
double pMut = 0.10;
std::string crit = "S";
bool verbose = false;
bclib::matrix<double> result = bclib::matrix<double>(n, k);

bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::geneticLHS(n, k, pop, gen, pMut, crit, verbose, result, oRandom);
View on GitHub
GitHub Stars10
CategoryDevelopment
Updated4mo ago
Forks1

Languages

C++

Security Score

92/100

Audited on Nov 18, 2025

No findings