30 #if defined (USE_SOBOL) 42 void samplePoints(M& xPoints,
int method, randEngine& mtRandom);
49 void lhs(M& Result,randEngine& mtRandom);
55 #if defined (USE_SOBOL) 57 void sobol(M& result,
long long int seed);
82 typedef typename D::iterator iter;
84 randInt sample(mtRandom, intUniformDist(0,arr.size()-1));
85 for (iter it=arr.begin(); it!=arr.end(); ++it)
86 iter_swap(arr.begin()+sample(),it);
91 void lhs(M& Result, randEngine& mtRandom)
93 randFloat sample( mtRandom, realUniformDist(0,1) );
94 size_t nA = Result.size1();
95 size_t nB = Result.size2();
96 double ndA =
static_cast<double>(nA);
99 for (
size_t i = 0; i < nB; i++)
105 for (
size_t j = 0; j < nA; j++)
107 Result(j,i) = (
static_cast<double>(perms[j]) - sample() ) / ndA;
112 #if defined (USE_SOBOL) 114 void sobol(M& result,
long long int seed)
116 size_t nSamples = result.size1();
117 size_t nDims = result.size2();
119 double *sobol_seq = i8_sobol_generate(nDims,nSamples,seed);
121 std::copy(sobol_seq,sobol_seq+(nSamples*nDims),result.data().begin());
127 randEngine& mtRandom)
129 randFloat sample( mtRandom, realUniformDist(0,1) );
130 size_t nA = Result.size1();
131 size_t nB = Result.size2();
135 for (
size_t i = 0; i < nA; i++)
136 for (
size_t j = 0; j < nB; j++)
137 Result(i,j) = sample();
142 randEngine& mtRandom)
146 FILE_LOG(logINFO) <<
"Latin hypercube sampling";
147 lhs(xPoints, mtRandom);
149 else if (method == 2)
151 #if defined (USE_SOBOL) 152 FILE_LOG(logINFO) <<
"Sobol sampling";
155 FILE_LOG(logINFO) <<
"Latin hypercube sampling";
156 lhs(xPoints, mtRandom);
161 FILE_LOG(logINFO) <<
"Uniform sampling";
Namespace of the library interface.
Generators for index vectors.
void lhs(M &Result, randEngine &mtRandom)
Latin hypercube sampling It is used to generate a uniform Latin hypercube.
void randomPerms(D &arr, randEngine &mtRandom)
Modify an array using ramdom permutations.
void samplePoints(M &xPoints, int method, randEngine &mtRandom)
Selects the sampling method.
Boost types for random number generation.
void uniformSampling(M &Result, randEngine &mtRandom)
Hypercube sampling based on Sobol sequences It uses the external Sobol library.
std::vector< int > return_index_vector(size_t n)
Generates a vector of indexes (1..n)
Modules and helper macros for logging.