https://github.com/bertcarnell/lhslib
Latin hypercube sampling code for the lhs pacakge in the statistical software package R (www.r-project.org)
https://github.com/bertcarnell/lhslib
c-plus-plus latin-hypercube-sampling r rcpp
Last synced: 3 months ago
JSON representation
Latin hypercube sampling code for the lhs pacakge in the statistical software package R (www.r-project.org)
- Host: GitHub
- URL: https://github.com/bertcarnell/lhslib
- Owner: bertcarnell
- License: gpl-2.0
- Created: 2013-11-20T19:53:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-03-19T00:17:14.000Z (about 3 years ago)
- Last Synced: 2023-10-20T18:12:42.687Z (over 1 year ago)
- Topics: c-plus-plus, latin-hypercube-sampling, r, rcpp
- Language: C++
- Homepage:
- Size: 915 KB
- Stars: 8
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
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](https://bertcarnell.github.io/lhslib/html/index.html).|Linux & MacOS|Windows|Code Coverage|Actions|CodeQL|Linter|
|:---:|:---:|:---:|:---:|:---:|:---:|
|[](https://travis-ci.org/bertcarnell/lhslib)|[](https://ci.appveyor.com/project/bertcarnell/lhslib)|[](https://codecov.io/gh/bertcarnell/lhslib)|[](https://github.com/bertcarnell/lhslib/actions)|[](https://github.com/bertcarnell/lhslib/actions)|[](https://github.com/bertcarnell/lhslib/actions)|## Connections to Other Projects
- [oa](https://github.com/bertcarnell/oa) orthogonal array project
- [bclib](https://github.com/bertcarnell/bclib) bertcarnell template library
- [lhs](https://bertcarnell.github.io/lhslib) package
- [R project](http://www.r-project.org)
- [lhs on CRAN](https://r-forge.r-project.org/projects/lhs/)
- [doxygen](http://www.stack.nl/~dimitri/doxygen/)## Documentation
The API is primarily documented through the Doxygen documentation supplied [here](http://bertcarnell.github.io/lhslib/).
## Examples
The following code illustrates how the API is called from C++. The `bclib::matrix` class is a simple matrix class that only
includes necessary operations ([bclib](https://github.com/bertcarnell/bclib)). More
robust matrix templates could be used in the future. `lhslib` is the namespace of this project.#### randomLHS Algorithm
```c
int n = 4;
int k = 3;
bool bPreserveDraw = false;
bclib::matrix result = bclib::matrix(n,k);bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::randomLHS(n, k, bPreserveDraw, result, oRandom);
```#### improvedLHS Algorithm
```c
int n = 4;
int k = 3;
int dup = 5;
bclib::matrix result = bclib::matrix(n,k);bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::improvedLHS(n, k, dup, result, oRandom);
```#### maximinLHS Algorithm
```c
int n = 4;
int k = 3;
int dup = 5;
bclib::matrix result = bclib::matrix(n, k);bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::maximinLHS(n, k, dup, result, oRandom);
```#### optimumLHS Algorithm
```c
int n = 4;
int k = 3;
int maxSweeps = 2;
double eps = 0.1;
int jLen = 7; // (4 choose 2) + 1
bclib::matrix result = bclib::matrix(n, k);bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::optimumLHS(n, k, maxSweeps, eps, result, jLen, oRandom, false);
```#### geneticLHS Algorithm
```c
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 result = bclib::matrix(n, k);bclib::CRandomStandardUniform oRandom = bclib::CRandomStandardUniform();
oRandom.setSeed(1976, 1968);
lhslib::geneticLHS(n, k, pop, gen, pMut, crit, verbose, result, oRandom);
```