tut::RNG_common struct

All tests in group inherited from this base.

Public static functions

template<class rng>
static void test_uniform(const rng& r)
template<class rng>
static void test_gaussian(const rng& r)
template<std::size_t D>
static auto cholesky(const std::array<double, D*(D+1)/2>& C) -> std::array<double, D*(D+1)/2>
template<std::size_t D, class rng>
static void test_gaussianmv(const rng& r, const std::array<double, D>& mean, const std::array<double, D*(D+1)/2>& C)
template<class rng>
static void test_beta(const rng& r)
template<class rng>
static void test_copy_ctor(const rng& r)
template<class rng>
static void test_move_ctor(const rng& r)
template<class rng>
static void test_copy_assignment(const rng& r)
template<class rng>
static void test_move_assignment(const rng& r)
static void test_stats(const std::vector<double>& numbers, double correct_mean, double correct_variance, double correct_skewness, double correct_excess_kurtosis)
template<std::size_t D>
static void test_statsmv(const std::vector<double>& numbers, const std::array<double, D>& correct_mean, const std::array<double, D*(D+1)/2>& correct_cov)

Constructors, destructors, conversion operators

RNG_common()
Constructor: create a vector of RNGs to be tested by most tests.

Public functions

template<class ModelCtor, typename... Args>
void add(std::vector<tk::RNG>& v, Args&&... args)
Add a model constructor bound to its arguments to a vector of objects modeling tk::RNG.

Function documentation

template<class rng>
static void tut::RNG_common::test_uniform(const rng& r)

Parameters
in RNG to test

Test uniform distribution of a random number generator In real code the member function used to generate random numbers are called by different threads, but here we pass a different thread ID (first argument to the member function called) will exercise multiple streams in serial, i.e., emulate multi-threaded RNG on a single thread. This is done here this way because the unit test harness deals out each test to a PE, thus calling the generators from real threads would create contention.

template<class rng>
static void tut::RNG_common::test_gaussian(const rng& r)

Parameters
in RNG to test

Test Gaussian distribution of a random number generator In real code the member function used to generate random numbers are called by different threads, but here we pass a different thread ID (first argument to the member function called) will exercise multiple streams in serial, i.e., emulate multi-threaded RNG on a single thread. This is done here this way because the unit test harness deals out each test to a PE, thus calling the generators from real threads would create contention.

template<std::size_t D>
static std::array<double, D*(D+1)/2> tut::RNG_common::cholesky(const std::array<double, D*(D+1)/2>& C)

Template parameters
D Number of dimensions of covariance matrix
Parameters
in Covariance matrix to decompose, only the upper diagonal and the diagonal are stored as the matrix is assumed to be symmetric (and positive definite)
Returns Choleksy decomposition (upper triangle only)

template<std::size_t D, class rng>
static void tut::RNG_common::test_gaussianmv(const rng& r, const std::array<double, D>& mean, const std::array<double, D*(D+1)/2>& C)

Template parameters
D Number of dimensions of covariance matrix
rng Random number generator class type whose instance to test
Parameters
in RNG to test
mean in Vector of means
in Upper triangle of the covariance matrix

Test multi-variate Gaussian distribution of a random number generator In real code the member function used to generate random numbers are called by different threads, but here we pass a different thread ID (first argument to the member function called) will exercise multiple streams in serial, i.e., emulate multi-threaded RNG on a single thread. This is done here this way because the unit test harness deals out each test to a PE, thus calling the generators from real threads would create contention.

template<class rng>
static void tut::RNG_common::test_beta(const rng& r)

Parameters
in RNG to test

Test beta distribution of a random number generator In real code the member function used to generate random numbers are called by different threads, but here we pass a different thread ID (first argument to the member function called) will exercise multiple streams in serial, i.e., emulate multi-threaded RNG on a single thread. This is done here this way because the unit test harness deals out each test to a PE, thus calling the generators from real threads would create contention.

template<class rng>
static void tut::RNG_common::test_copy_ctor(const rng& r)

Parameters
in RNG to test

Test copy constructor of a random number generator

template<class rng>
static void tut::RNG_common::test_move_ctor(const rng& r)

Parameters
in RNG to test

Test move constructor of a random number generator

template<class rng>
static void tut::RNG_common::test_copy_assignment(const rng& r)

Parameters
in RNG to test

Test copy assignment of a random number generator

template<class rng>
static void tut::RNG_common::test_move_assignment(const rng& r)

Parameters
in RNG to test

Test move assignment of a random number generator

static void tut::RNG_common::test_stats(const std::vector<double>& numbers, double correct_mean, double correct_variance, double correct_skewness, double correct_excess_kurtosis)

Parameters
numbers in Random numbers to test
correct_mean in Baseline mean to compare to
correct_variance in Baseline variance to compare to
correct_skewness in Baseline skewness to compare to
correct_excess_kurtosis in Baseline excess kurtosis to compare to

template<std::size_t D>
static void tut::RNG_common::test_statsmv(const std::vector<double>& numbers, const std::array<double, D>& correct_mean, const std::array<double, D*(D+1)/2>& correct_cov)

Template parameters
D Number of dimensions of sample space in multi-variate distribution
Parameters
numbers in Random vectors to test, size: num*D, vector size: D
correct_mean in Baseline mean vector to compare to
correct_cov in Baseline covariance matrix to compare to