Latin Hypercube Samples (lhs)
1.0
R, C++, and Rcpp code to generate Latin hypercube samples
|
Classes | |
struct | invert |
struct | squareDifference |
Typedefs | |
typedef bclib::matrix< int >::size_type | msize_type |
typedef std::vector< int >::size_type | vsize_type |
Functions | |
void | geneticLHS (int n, int k, int pop, int gen, double pMut, const std::string &criterium, bool bVerbose, bclib::matrix< double > &result, bclib::CRandom< double > &oRandom) |
void | improvedLHS (int n, int k, int dup, bclib::matrix< int > &result, bclib::CRandom< double > &oRandom) |
void | maximinLHS (int n, int k, int dup, bclib::matrix< int > &result, bclib::CRandom< double > &oRandom) |
void | optimumLHS (int n, int k, int maxSweeps, double eps, bclib::matrix< int > &outlhs, int optimalityRecordLength, bclib::CRandom< double > &oRandom, bool bVerbose) |
void | optSeededLHS (int n, int k, int maxSweeps, double eps, bclib::matrix< double > &oldHypercube, int optimalityRecordLength, bool bVerbose) |
void | randomLHS (int n, int k, bool bPreserveDraw, bclib::matrix< double > &result, bclib::CRandom< double > &oRandom) |
void | randomLHS (int n, int k, bclib::matrix< int > &result, bclib::CRandom< double > &oRandom) |
bool | isValidLHS (const bclib::matrix< int > &result) |
bool | isValidLHS (const bclib::matrix< double > &result) |
void | initializeAvailableMatrix (bclib::matrix< int > &avail) |
void | runif_std (unsigned int n, std::vector< double > &output, bclib::CRandom< double > &oRandom) |
template<class T > | |
void | rank (const std::vector< T > &toRank, std::vector< int > &ranks) |
template<class T > | |
void | lhsPrint (const bclib::matrix< T > &A) |
template<class T > | |
T | calculateDistanceSquared (const std::vector< T > &A, const std::vector< T > &B) |
template<class T , bool ISROWWISE> | |
T | calculateDistanceSquared (const typename bclib::matrixConstIter< T, ISROWWISE > Abegin, const typename bclib::matrixConstIter< T, ISROWWISE > Aend, const typename bclib::matrixConstIter< T, ISROWWISE > Bbegin) |
template<class T > | |
void | calculateDistance (const bclib::matrix< T > &mat, bclib::matrix< double > &result) |
template<class T > | |
double | sumInvDistance (const bclib::matrix< T > &A) |
template<class T > | |
double | sumInvDistance_deprecated (const bclib::matrix< T > &A) |
template<class T > | |
void | copyMatrix (bclib::matrix< T > ©To, const bclib::matrix< T > ©From) |
template<class T > | |
double | calculateSOptimal (const bclib::matrix< T > &mat) |
template<class T1 > | |
void | runifint (unsigned int n, T1 min, T1 max, std::vector< T1 > &output, bclib::CRandom< double > &oRandom) |
template<class T1 > | |
void | runifint (T1 min, T1 max, T1 *output, bclib::CRandom< double > &oRandom) |
LHS c++ Library namespace
typedef bclib::matrix<int>::size_type lhslib::msize_type |
type of size type for use with bclib::matrix<T>
typedef std::vector<int>::size_type lhslib::vsize_type |
type of size type for use with std::vector<T>
void lhslib::calculateDistance | ( | const bclib::matrix< T > & | mat, |
bclib::matrix< double > & | result | ||
) |
Calculate the distance between the rows of a matrix
mat | the matrix to calculate distances on |
result | the matrix to hold the results of the calculation |
T | the type of object in the matrix |
T lhslib::calculateDistanceSquared | ( | const std::vector< T > & | A, |
const std::vector< T > & | B | ||
) |
Calculate the total squared distance between two vectors
A | the first vector |
B | the second vector |
T | the type of the objects in the vector |
T lhslib::calculateDistanceSquared | ( | const typename bclib::matrixConstIter< T, ISROWWISE > | Abegin, |
const typename bclib::matrixConstIter< T, ISROWWISE > | Aend, | ||
const typename bclib::matrixConstIter< T, ISROWWISE > | Bbegin | ||
) |
Calculate the distance squared between two sequence of numbers
this was primarily implemented to be able to calculate distances between rows of a matrix without having to copy those rows out
Abegin | the beginning of the first iterator |
Aend | the end of the first iterator |
Bbegin | the beginning of the second iterator |
T | the type of object de-referenced by the iterator |
ISROWWISE | a boolean to indicate if the iterator operates row-wise in the matrix |
double lhslib::calculateSOptimal | ( | const bclib::matrix< T > & | mat | ) |
Calculate the S optimality measure
mat | the matrix to calculate S optimality for |
the | type of object contained in the matrix |
void lhslib::copyMatrix | ( | bclib::matrix< T > & | copyTo, |
const bclib::matrix< T > & | copyFrom | ||
) |
Copy a matrix
copyTo | the matrix to copy to |
copyFrom | the matrix to copy from |
the | type of object contained in the matrix |
void lhslib::geneticLHS | ( | int | n, |
int | k, | ||
int | pop, | ||
int | gen, | ||
double | pMut, | ||
const std::string & | criterium, | ||
bool | bVerbose, | ||
bclib::matrix< double > & | result, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Create a latin hypercube sample optimized by some criteria with a genetic algorithm
n | number of rows / samples in the lhs |
k | number parameters / columns in the lhs |
pop | the population of the genetic algorithm in each iteration |
gen | the number of generations to use |
pMut | the mutation rate |
criterium | the optimization criterium |
bVerbose | should messages be printed? |
result | the lhs |
oRandom | the random number stream |
void lhslib::improvedLHS | ( | int | n, |
int | k, | ||
int | dup, | ||
bclib::matrix< int > & | result, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Improved Latin hypercube sample algorithm
n | number of rows / samples in the lha |
k | number parameters / columns in the lhs |
dup | A factor that determines the number of candidate points used in the search. |
result | the result matrix |
oRandom | the random number stream |
void lhslib::initializeAvailableMatrix | ( | bclib::matrix< int > & | avail | ) |
Initialize the matrix of available points
avail | the matrix of available points |
bool lhslib::isValidLHS | ( | const bclib::matrix< double > & | result | ) |
is the Latin hypercube sample valid?
result | the latin hypercube sample |
bool lhslib::isValidLHS | ( | const bclib::matrix< int > & | result | ) |
is the Latin hypercube sample valid
result | the latin hypercube sample with integer values |
void lhslib::lhsPrint | ( | const bclib::matrix< T > & | A | ) |
print the Latin hypercube sample
A | the matrix to print |
T | the type of matrix to print |
void lhslib::maximinLHS | ( | int | n, |
int | k, | ||
int | dup, | ||
bclib::matrix< int > & | result, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Latin hypercube sample algorithm with maximin criterion
n | number of rows / samples in the lha |
k | number parameters / columns in the lhs |
dup | A factor that determines the number of candidate points used in the search. |
result | the result matrix |
oRandom | the random number stream |
void lhslib::optimumLHS | ( | int | n, |
int | k, | ||
int | maxSweeps, | ||
double | eps, | ||
bclib::matrix< int > & | outlhs, | ||
int | optimalityRecordLength, | ||
bclib::CRandom< double > & | oRandom, | ||
bool | bVerbose | ||
) |
Optimum Latin hypercube sample algorithm
n | number of rows / samples in the lha |
k | number parameters / columns in the lhs |
maxSweeps | the maximum number of sweeps to use in the algorithm |
eps | The optimal stopping criterion |
outlhs | the resultant lhs |
optimalityRecordLength | the length of a vector used in the calculations |
oRandom | the random number stream |
bVerbose | should messages be printed? |
void lhslib::optSeededLHS | ( | int | n, |
int | k, | ||
int | maxSweeps, | ||
double | eps, | ||
bclib::matrix< double > & | oldHypercube, | ||
int | optimalityRecordLength, | ||
bool | bVerbose | ||
) |
Application of the optimum lhs method to a seeded Latin hypercube
n | number of rows / samples in the lhs |
k | number parameters / columns in the lhs |
maxSweeps | the maximum number of sweeps to use in the algorithm |
eps | The optimal stopping criterion |
oldHypercube | the seeded lhs |
optimalityRecordLength | the length of a vector used in the calculations |
bVerbose | should messages be printed? |
void lhslib::randomLHS | ( | int | n, |
int | k, | ||
bclib::matrix< int > & | result, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Create a random latin hypercube sample with integer values
n | number of rows / samples in the lhs |
k | number parameters / columns in the lhs |
result | the lhs |
oRandom | the random number stream |
void lhslib::randomLHS | ( | int | n, |
int | k, | ||
bool | bPreserveDraw, | ||
bclib::matrix< double > & | result, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Create a random latin hypercube sample
n | number of rows / samples in the lhs |
k | number parameters / columns in the lhs |
bPreserveDraw | should the order of the draw be preserved if less columns are selected |
result | the lhs |
oRandom | the random number stream |
void lhslib::rank | ( | const std::vector< T > & | toRank, |
std::vector< int > & | ranks | ||
) |
rank a vector of objects
toRank | the vector of objects to rank |
ranks | the ranks of the vector of values |
the | type of element in the vectors |
void lhslib::runif_std | ( | unsigned int | n, |
std::vector< double > & | output, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Create a vector of random values on (0,1)
n | the number of random values |
output | the output vector of random values |
oRandom | the pseudo random number generator |
void lhslib::runifint | ( | T1 | min, |
T1 | max, | ||
T1 * | output, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Create a random integer like values
min | the minimum integer value |
max | the maximum integer value |
output | the output value |
oRandom | the pseudo random number generator |
T1 | the integer valued type like int, unsigned int, long, long long, unsigned long |
void lhslib::runifint | ( | unsigned int | n, |
T1 | min, | ||
T1 | max, | ||
std::vector< T1 > & | output, | ||
bclib::CRandom< double > & | oRandom | ||
) |
Create a vector of random integer like values
n | the length of the random vector |
min | the minimum integer value |
max | the maximum integer value |
output | the output vector of values |
oRandom | the pseudo random number generator. |
T1 | the integer valued type like int, unsigned int, long, long long, unsigned long |
double lhslib::sumInvDistance | ( | const bclib::matrix< T > & | A | ) |
sum of the inverse distance between points in a matrix
A | the matrix |
T | the type of object contained in the matrix |
double lhslib::sumInvDistance_deprecated | ( | const bclib::matrix< T > & | A | ) |
Sum of the inverse distance between points
A | the matrix to sum |
T | the type of object in the matrix |