sampler#

Structs#

Sampler#

template<typename T>
struct Sampler#

Subclassed by ioh::common::random::sampler::Uniform< T >

Public Types

using seed_type = long long int#

Public Functions

inline Sampler(const size_t n, const seed_type seed, const T lb, const T ub)#
virtual std::vector<T> next() = 0#

Public Static Attributes

static seed_type default_seed = 1993#

Protected Attributes

size_t n#
seed_type seed#
T lb#
T ub#

Uniform#

template<typename T>
struct Uniform : public ioh::common::random::sampler::Sampler<T>#

Public Types

using seed_type = long long int#

Public Functions

inline Uniform(const size_t n, const seed_type seed = default_seed, const T lb = 0, const T ub = 1)#
inline virtual std::vector<T> next() override#

Public Static Attributes

static seed_type default_seed = 1993#

Private Members

std::mt19937 gen_#
size_t delta_g_#
T delta_#

Sobol#

struct Sobol : public ioh::common::random::sampler::Sampler<double>#

Public Functions

inline Sobol(const size_t n, const seed_type seed = Sampler::default_seed, const double lb = 0, const double ub = 1)#
inline virtual std::vector<double> next() override#

Halton#

struct Halton : public ioh::common::random::sampler::Sampler<double>#

Public Functions

inline Halton(const size_t n, const seed_type seed = Sampler::default_seed, const double lb = 0, const double ub = 1)#
inline virtual std::vector<double> next() override#

Private Members

double delta#
std::vector<int> primes#

Private Static Functions

static inline std::pair<int, int> divmod(const double top, const double bottom)#
static inline std::vector<int> sieve(const int n_samples)#
static inline double next_seq(int index, const int base)#

Functions#

i8_bit_lo0#

inline int ioh::common::random::sampler::i8_bit_lo0(long long int n)#

Purpose:

I8_BIT_LO0 returns the position of the low 0 bit base 2 in an integer.

Example:

 N    Binary    Lo 0
0 0 1 1 1 2 2 10 1 3 11 3 4 100 1 5 101 2 6 110 1 7 111 4 8 1000 1 9 1001 2 10 1010 1 11 1011 3 12 1100 1 13 1101 2 14 1110 1 15 1111 5 16 10000 1 17 10001 2 1023 1111111111 11 1024 10000000000 1 1025 10000000001 2

Licensing:

This code is distributed under the GNU LGPL license.

Modified:

12 May 2007

Author:

John Burkardt

Parameters:

Input, long long int N, the integer to be measured. N should be nonnegative.

Output, int I8_BIT_LO0, the position of the low 1 bit.

i8_sobol#

inline void ioh::common::random::sampler::i8_sobol(int dim_num, long long int *seed, double quasi[], double lb = 0, double ub = 1)#

Purpose:

I8_SOBOL generates a new quasirandom Sobol vector with each call.

Discussion:

The routine adapts the ideas of Antonov and Saleev.

This routine uses LONG LONG INT for integers and DOUBLE for real values.

Thanks to Steffan Berridge for supplying (twice) the properly formatted V data needed to extend the original routine’s dimension limit from 40 to 1111, 05 June 2007.

Thanks to Francis Dalaudier for pointing out that the range of allowed values of DIM_NUM should start at 1, not 2! 17 February 2009.

Licensing:

This code is distributed under the GNU LGPL license.

Modified:

17 February 2009

Author:

FORTRAN77 original version by Bennett Fox. C++ version by John Burkardt

Reference:

IA Antonov, VM Saleev, An Economic Method of Computing LP Tau-Sequences, USSR Computational Mathematics and Mathematical Physics, Volume 19, 1980, pages 252 - 256.

Paul Bratley, Bennett Fox, Algorithm 659: Implementing Sobol’s Quasirandom Sequence Generator, ACM Transactions on Mathematical Software, Volume 14, Number 1, pages 88-100, 1988.

Bennett Fox, Algorithm 647: Implementation and Relative Efficiency of Quasirandom Sequence Generators, ACM Transactions on Mathematical Software, Volume 12, Number 4, pages 362-376, 1986.

Stephen Joe, Frances Kuo Remark on Algorithm 659: Implementing Sobol’s Quasirandom Sequence Generator, ACM Transactions on Mathematical Software, Volume 29, Number 1, pages 49-57, March 2003.

Ilya Sobol, USSR Computational Mathematics and Mathematical Physics, Volume 16, pages 236-242, 1977.

Ilya Sobol, YL Levitan, The Production of Points Uniformly Distributed in a Multidimensional Cube (in Russian), Preprint IPM Akad. Nauk SSSR, Number 40, Moscow 1976.

Parameters:

Input, int DIM_NUM, the number of spatial dimensions. DIM_NUM must satisfy 1 <= DIM_NUM <= 1111.

Input/output, long long int *SEED, the “seed” for the sequence. This is essentially the index in the sequence of the quasirandom value to be generated. On output, SEED has been set to the appropriate next value, usually simply SEED+1. If SEED is less than 0 on input, it is treated as though it were 0. An input value of 0 requests the first (0-th) element of the sequence.

Output, double QUASI[DIM_NUM], the next quasirandom vector.