summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/random
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:45:59 +0000
commit19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch)
tree42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/boost/libs/random
parentInitial commit. (diff)
downloadceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz
ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/boost/libs/random')
-rw-r--r--src/boost/libs/random/build/Jamfile.v218
-rw-r--r--src/boost/libs/random/example/Jamfile.v213
-rw-r--r--src/boost/libs/random/example/die.cpp60
-rw-r--r--src/boost/libs/random/example/intersections.cpp78
-rw-r--r--src/boost/libs/random/example/password.cpp49
-rw-r--r--src/boost/libs/random/example/random_demo.cpp110
-rw-r--r--src/boost/libs/random/example/weighted_die.cpp55
-rw-r--r--src/boost/libs/random/extra/Jamfile.v210
-rw-r--r--src/boost/libs/random/extra/haertel.hpp156
-rw-r--r--src/boost/libs/random/extra/test_haertel.cpp62
-rw-r--r--src/boost/libs/random/index.html14
-rw-r--r--src/boost/libs/random/meta/libraries.json17
-rw-r--r--src/boost/libs/random/nondet_random.html17
-rw-r--r--src/boost/libs/random/performance/Jamfile.v218
-rw-r--r--src/boost/libs/random/performance/generate_table.cpp133
-rw-r--r--src/boost/libs/random/performance/nondet_random_speed.cpp60
-rw-r--r--src/boost/libs/random/performance/random_speed.cpp399
-rw-r--r--src/boost/libs/random/random-concepts.html17
-rw-r--r--src/boost/libs/random/random-distributions.html17
-rw-r--r--src/boost/libs/random/random-generators.html17
-rw-r--r--src/boost/libs/random/random-misc.html17
-rw-r--r--src/boost/libs/random/random-performance.html17
-rw-r--r--src/boost/libs/random/random-variate.html17
-rw-r--r--src/boost/libs/random/src/random_device.cpp250
-rw-r--r--src/boost/libs/random/test/Jamfile.v2147
-rw-r--r--src/boost/libs/random/test/chi_squared_test.hpp92
-rw-r--r--src/boost/libs/random/test/concepts.hpp210
-rw-r--r--src/boost/libs/random/test/faure_validate.cpp375
-rw-r--r--src/boost/libs/random/test/histogram.cpp165
-rw-r--r--src/boost/libs/random/test/integrate.hpp79
-rw-r--r--src/boost/libs/random/test/multiprecision_float_test.cpp198
-rw-r--r--src/boost/libs/random/test/multiprecision_int_test.cpp225
-rw-r--r--src/boost/libs/random/test/niederreiter_base2_validate.cpp379
-rw-r--r--src/boost/libs/random/test/sobol_validate.cpp380
-rw-r--r--src/boost/libs/random/test/statistic_tests.cpp503
-rw-r--r--src/boost/libs/random/test/statistic_tests.hpp709
-rw-r--r--src/boost/libs/random/test/test_bernoulli.cpp108
-rw-r--r--src/boost/libs/random/test/test_bernoulli_distribution.cpp32
-rw-r--r--src/boost/libs/random/test/test_beta.cpp28
-rw-r--r--src/boost/libs/random/test/test_beta_distribution.cpp38
-rw-r--r--src/boost/libs/random/test/test_binomial.cpp30
-rw-r--r--src/boost/libs/random/test/test_binomial_distribution.cpp37
-rw-r--r--src/boost/libs/random/test/test_cauchy.cpp28
-rw-r--r--src/boost/libs/random/test/test_cauchy_distribution.cpp35
-rw-r--r--src/boost/libs/random/test/test_chi_squared.cpp24
-rw-r--r--src/boost/libs/random/test/test_chi_squared_distribution.cpp34
-rw-r--r--src/boost/libs/random/test/test_const_mod.cpp183
-rw-r--r--src/boost/libs/random/test/test_discrete.cpp123
-rw-r--r--src/boost/libs/random/test/test_discrete_distribution.cpp168
-rw-r--r--src/boost/libs/random/test/test_distribution.ipp290
-rw-r--r--src/boost/libs/random/test/test_ecuyer1988.cpp24
-rw-r--r--src/boost/libs/random/test/test_exponential.cpp24
-rw-r--r--src/boost/libs/random/test/test_exponential_distribution.cpp32
-rw-r--r--src/boost/libs/random/test/test_extreme_value.cpp28
-rw-r--r--src/boost/libs/random/test/test_extreme_value_distribution.cpp36
-rw-r--r--src/boost/libs/random/test/test_fisher_f.cpp28
-rw-r--r--src/boost/libs/random/test/test_fisher_f_distribution.cpp33
-rw-r--r--src/boost/libs/random/test/test_gamma.cpp28
-rw-r--r--src/boost/libs/random/test/test_gamma_distribution.cpp37
-rw-r--r--src/boost/libs/random/test/test_generate_canonical.cpp104
-rw-r--r--src/boost/libs/random/test/test_generator.ipp279
-rw-r--r--src/boost/libs/random/test/test_geometric.cpp26
-rw-r--r--src/boost/libs/random/test/test_geometric_distribution.cpp31
-rw-r--r--src/boost/libs/random/test/test_hellekalek1995.cpp24
-rw-r--r--src/boost/libs/random/test/test_hyperexponential.cpp225
-rw-r--r--src/boost/libs/random/test/test_hyperexponential_distribution.cpp467
-rw-r--r--src/boost/libs/random/test/test_independent_bits31.cpp26
-rw-r--r--src/boost/libs/random/test/test_independent_bits32.cpp26
-rw-r--r--src/boost/libs/random/test/test_knuth_b.cpp26
-rw-r--r--src/boost/libs/random/test/test_kreutzer1986.cpp26
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci.cpp25
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci1279.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci19937.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci2281.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci23209.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci3217.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci4423.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci44497.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci607.cpp24
-rw-r--r--src/boost/libs/random/test/test_lagged_fibonacci9689.cpp24
-rw-r--r--src/boost/libs/random/test/test_laplace.cpp28
-rw-r--r--src/boost/libs/random/test/test_laplace_distribution.cpp36
-rw-r--r--src/boost/libs/random/test/test_linear_feedback_shift.cpp25
-rw-r--r--src/boost/libs/random/test/test_lognormal.cpp28
-rw-r--r--src/boost/libs/random/test/test_lognormal_distribution.cpp36
-rw-r--r--src/boost/libs/random/test/test_minstd_rand.cpp26
-rw-r--r--src/boost/libs/random/test/test_minstd_rand0.cpp26
-rw-r--r--src/boost/libs/random/test/test_mt11213b.cpp26
-rw-r--r--src/boost/libs/random/test/test_mt19937.cpp81
-rw-r--r--src/boost/libs/random/test/test_mt19937_64.cpp28
-rw-r--r--src/boost/libs/random/test/test_negative_binomial.cpp30
-rw-r--r--src/boost/libs/random/test/test_negative_binomial_distribution.cpp37
-rw-r--r--src/boost/libs/random/test/test_non_central_chi_squared.cpp29
-rw-r--r--src/boost/libs/random/test/test_non_central_chi_squared_distribution.cpp39
-rw-r--r--src/boost/libs/random/test/test_normal.cpp28
-rw-r--r--src/boost/libs/random/test/test_normal_distribution.cpp36
-rw-r--r--src/boost/libs/random/test/test_old_uniform_int.cpp26
-rw-r--r--src/boost/libs/random/test/test_old_uniform_int_distribution.cpp78
-rw-r--r--src/boost/libs/random/test/test_old_uniform_real.cpp25
-rw-r--r--src/boost/libs/random/test/test_old_uniform_real_distribution.cpp38
-rw-r--r--src/boost/libs/random/test/test_piecewise_constant.cpp158
-rw-r--r--src/boost/libs/random/test/test_piecewise_constant_distribution.cpp246
-rw-r--r--src/boost/libs/random/test/test_piecewise_linear.cpp175
-rw-r--r--src/boost/libs/random/test/test_piecewise_linear_distribution.cpp252
-rw-r--r--src/boost/libs/random/test/test_poisson.cpp25
-rw-r--r--src/boost/libs/random/test/test_poisson_distribution.cpp33
-rw-r--r--src/boost/libs/random/test/test_qrng_functions.hpp278
-rw-r--r--src/boost/libs/random/test/test_rand48.cpp26
-rw-r--r--src/boost/libs/random/test/test_random_device.cpp29
-rw-r--r--src/boost/libs/random/test/test_random_number_generator.cpp35
-rw-r--r--src/boost/libs/random/test/test_ranlux24.cpp26
-rw-r--r--src/boost/libs/random/test/test_ranlux24_base.cpp25
-rw-r--r--src/boost/libs/random/test/test_ranlux3.cpp25
-rw-r--r--src/boost/libs/random/test/test_ranlux3_01.cpp26
-rw-r--r--src/boost/libs/random/test/test_ranlux4.cpp25
-rw-r--r--src/boost/libs/random/test/test_ranlux48.cpp26
-rw-r--r--src/boost/libs/random/test/test_ranlux48_base.cpp26
-rw-r--r--src/boost/libs/random/test/test_ranlux4_01.cpp26
-rw-r--r--src/boost/libs/random/test/test_ranlux64_3.cpp27
-rw-r--r--src/boost/libs/random/test/test_ranlux64_3_01.cpp26
-rw-r--r--src/boost/libs/random/test/test_ranlux64_4.cpp27
-rw-r--r--src/boost/libs/random/test/test_ranlux64_4_01.cpp26
-rw-r--r--src/boost/libs/random/test/test_real_distribution.ipp195
-rw-r--r--src/boost/libs/random/test/test_seed_seq.cpp130
-rw-r--r--src/boost/libs/random/test/test_student_t.cpp24
-rw-r--r--src/boost/libs/random/test/test_student_t_distribution.cpp29
-rw-r--r--src/boost/libs/random/test/test_taus88.cpp24
-rw-r--r--src/boost/libs/random/test/test_triangle.cpp26
-rw-r--r--src/boost/libs/random/test/test_triangle_distribution.cpp41
-rw-r--r--src/boost/libs/random/test/test_uniform_int.cpp27
-rw-r--r--src/boost/libs/random/test/test_uniform_int.ipp149
-rw-r--r--src/boost/libs/random/test/test_uniform_int_distribution.cpp42
-rw-r--r--src/boost/libs/random/test/test_uniform_on_sphere.cpp45
-rw-r--r--src/boost/libs/random/test/test_uniform_on_sphere_distribution.cpp87
-rw-r--r--src/boost/libs/random/test/test_uniform_real.cpp26
-rw-r--r--src/boost/libs/random/test/test_uniform_real_distribution.cpp48
-rw-r--r--src/boost/libs/random/test/test_uniform_smallint.cpp27
-rw-r--r--src/boost/libs/random/test/test_uniform_smallint_distribution.cpp38
-rw-r--r--src/boost/libs/random/test/test_weibull.cpp28
-rw-r--r--src/boost/libs/random/test/test_weibull_distribution.cpp36
-rw-r--r--src/boost/libs/random/test/test_zero_seed.cpp29
141 files changed, 11337 insertions, 0 deletions
diff --git a/src/boost/libs/random/build/Jamfile.v2 b/src/boost/libs/random/build/Jamfile.v2
new file mode 100644
index 000000000..b4e9ceae3
--- /dev/null
+++ b/src/boost/libs/random/build/Jamfile.v2
@@ -0,0 +1,18 @@
+# Jamfile.v2
+#
+# Copyright (c) 2010
+# Steven Watanabe
+#
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+project /boost/random
+ : source-location ../src
+ : requirements <link>shared:<define>BOOST_RANDOM_DYN_LINK
+ : usage-requirements <link>shared:<define>BOOST_RANDOM_DYN_LINK
+;
+
+lib boost_random : [ glob *.cpp ] /boost//system ;
+
+boost-install boost_random ;
diff --git a/src/boost/libs/random/example/Jamfile.v2 b/src/boost/libs/random/example/Jamfile.v2
new file mode 100644
index 000000000..c598e7864
--- /dev/null
+++ b/src/boost/libs/random/example/Jamfile.v2
@@ -0,0 +1,13 @@
+# Jamfile.v2
+#
+# Copyright (c) 2009
+# Steven Watanabe
+#
+# Distributed under the Boost Software License, Version 1.0. (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+run die.cpp ;
+run weighted_die.cpp ;
+run password.cpp /boost//random ;
+run intersections.cpp /boost//random ;
diff --git a/src/boost/libs/random/example/die.cpp b/src/boost/libs/random/example/die.cpp
new file mode 100644
index 000000000..5626a2ed3
--- /dev/null
+++ b/src/boost/libs/random/example/die.cpp
@@ -0,0 +1,60 @@
+// die.cpp
+//
+// Copyright (c) 2009
+// Steven Watanabe
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[die
+/*`
+ For the source of this example see
+ [@boost://libs/random/example/die.cpp die.cpp].
+ First we include the headers we need for __mt19937
+ and __uniform_int_distribution.
+*/
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/uniform_int_distribution.hpp>
+
+/*`
+ We use __mt19937 with the default seed as a source of
+ randomness. The numbers produced will be the same
+ every time the program is run. One common method to
+ change this is to seed with the current time (`std::time(0)`
+ defined in ctime).
+*/
+boost::random::mt19937 gen;
+/*`
+ [note We are using a /global/ generator object here. This
+ is important because we don't want to create a new [prng
+ pseudo-random number generator] at every call]
+*/
+/*`
+ Now we can define a function that simulates an ordinary
+ six-sided die.
+*/
+int roll_die() {
+ /*<< __mt19937 produces integers in the range [0, 2[sup 32]-1].
+ However, we want numbers in the range [1, 6]. The distribution
+ __uniform_int_distribution performs this transformation.
+ [warning Contrary to common C++ usage __uniform_int_distribution
+ does not take a /half-open range/. Instead it takes a /closed range/.
+ Given the parameters 1 and 6, __uniform_int_distribution
+ can produce any of the values 1, 2, 3, 4, 5, or 6.]
+ >>*/
+ boost::random::uniform_int_distribution<> dist(1, 6);
+ /*<< A distribution is a function object. We generate a random
+ number by calling `dist` with the generator.
+ >>*/
+ return dist(gen);
+}
+//]
+
+#include <iostream>
+
+int main() {
+ for(int i = 0; i < 10; ++i) {
+ std::cout << roll_die() << std::endl;
+ }
+}
diff --git a/src/boost/libs/random/example/intersections.cpp b/src/boost/libs/random/example/intersections.cpp
new file mode 100644
index 000000000..fea40d6a4
--- /dev/null
+++ b/src/boost/libs/random/example/intersections.cpp
@@ -0,0 +1,78 @@
+// intersections.cpp
+//
+// Copyright (c) 2018
+// Justinas V. Daugmaudis
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[intersections
+/*`
+ For the source of this example see
+ [@boost://libs/random/example/intersections.cpp intersections.cpp].
+
+ This example demonstrates generating quasi-randomly distributed chord
+ entry and exit points on an S[sup 2] sphere.
+
+ First we include the headers we need for __niederreiter_base2
+ and __uniform_01 distribution.
+ */
+
+#include <boost/random/niederreiter_base2.hpp>
+#include <boost/random/uniform_01.hpp>
+
+#include <boost/math/constants/constants.hpp>
+
+#include <boost/tuple/tuple.hpp>
+
+/*`
+ We use 4-dimensional __niederreiter_base2 as a source of randomness.
+ */
+boost::random::niederreiter_base2 gen(4);
+
+
+int main()
+{
+ typedef boost::tuple<double, double, double> point_t;
+
+ const std::size_t n_points = 100; // we will generate 100 points
+
+ std::vector<point_t> points;
+ points.reserve(n_points);
+
+ /*<< __niederreiter_base2 produces integers in the range [0, 2[sup 64]-1].
+ However, we want numbers in the range [0, 1). The distribution
+ __uniform_01 performs this transformation.
+ >>*/
+ boost::random::uniform_01<double> dist;
+
+ for (std::size_t i = 0; i != n_points; ++i)
+ {
+ /*`
+ Using formula from J. Rovira et al., "Point sampling with uniformly distributed lines", 2005
+ to compute uniformly distributed chord entry and exit points on the surface of a sphere.
+ */
+ double cos_theta = 1 - 2 * dist(gen);
+ double sin_theta = std::sqrt(1 - cos_theta * cos_theta);
+ double phi = boost::math::constants::two_pi<double>() * dist(gen);
+ double sin_phi = std::sin(phi), cos_phi = std::cos(phi);
+
+ point_t point_on_sphere(sin_theta*sin_phi, cos_theta, sin_theta*cos_phi);
+
+ /*`
+ Here we assume that our sphere is a unit sphere at origin. If your sphere was
+ different then now would be the time to scale and translate the `point_on_sphere`.
+ */
+
+ points.push_back(point_on_sphere);
+ }
+
+ /*`
+ Vector `points` now holds generated 3D points on a sphere.
+ */
+
+ return 0;
+}
+
+//]
diff --git a/src/boost/libs/random/example/password.cpp b/src/boost/libs/random/example/password.cpp
new file mode 100644
index 000000000..273b4c817
--- /dev/null
+++ b/src/boost/libs/random/example/password.cpp
@@ -0,0 +1,49 @@
+// password.cpp
+//
+// Copyright (c) 2010
+// Steven Watanabe
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[password
+/*`
+ For the source of this example see
+ [@boost://libs/random/example/password.cpp password.cpp].
+
+ This example demonstrates generating a random 8 character
+ password.
+ */
+
+
+#include <boost/random/random_device.hpp>
+#include <boost/random/uniform_int_distribution.hpp>
+#include <iostream>
+
+int main() {
+ /*<< We first define the characters that we're going
+ to allow. This is pretty much just the characters
+ on a standard keyboard.
+ >>*/
+ std::string chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "1234567890"
+ "!@#$%^&*()"
+ "`~-_=+[{]}\\|;:'\",<.>/? ");
+ /*<< We use __random_device as a source of entropy, since we want
+ passwords that are not predictable.
+ >>*/
+ boost::random::random_device rng;
+ /*<< Finally we select 8 random characters from the
+ string and print them to cout.
+ >>*/
+ boost::random::uniform_int_distribution<> index_dist(0, chars.size() - 1);
+ for(int i = 0; i < 8; ++i) {
+ std::cout << chars[index_dist(rng)];
+ }
+ std::cout << std::endl;
+}
+
+//]
diff --git a/src/boost/libs/random/example/random_demo.cpp b/src/boost/libs/random/example/random_demo.cpp
new file mode 100644
index 000000000..593c757d2
--- /dev/null
+++ b/src/boost/libs/random/example/random_demo.cpp
@@ -0,0 +1,110 @@
+/* boost random_demo.cpp profane demo
+ *
+ * Copyright Jens Maurer 2000
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ * A short demo program how to use the random number library.
+ */
+
+#include <iostream>
+#include <fstream>
+#include <ctime> // std::time
+
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/generator_iterator.hpp>
+
+// This is a typedef for a random number generator.
+// Try boost::mt19937 or boost::ecuyer1988 instead of boost::minstd_rand
+typedef boost::minstd_rand base_generator_type;
+
+// This is a reproducible simulation experiment. See main().
+void experiment(base_generator_type & generator)
+{
+ // Define a uniform random number distribution of integer values between
+ // 1 and 6 inclusive.
+ typedef boost::uniform_int<> distribution_type;
+ typedef boost::variate_generator<base_generator_type&, distribution_type> gen_type;
+ gen_type die_gen(generator, distribution_type(1, 6));
+
+ // If you want to use an STL iterator interface, use iterator_adaptors.hpp.
+ boost::generator_iterator<gen_type> die(&die_gen);
+ for(int i = 0; i < 10; i++)
+ std::cout << *die++ << " ";
+ std::cout << '\n';
+}
+
+int main()
+{
+ // Define a random number generator and initialize it with a reproducible
+ // seed.
+ base_generator_type generator(42);
+
+ std::cout << "10 samples of a uniform distribution in [0..1):\n";
+
+ // Define a uniform random number distribution which produces "double"
+ // values between 0 and 1 (0 inclusive, 1 exclusive).
+ boost::uniform_real<> uni_dist(0,1);
+ boost::variate_generator<base_generator_type&, boost::uniform_real<> > uni(generator, uni_dist);
+
+ std::cout.setf(std::ios::fixed);
+ // You can now retrieve random numbers from that distribution by means
+ // of a STL Generator interface, i.e. calling the generator as a zero-
+ // argument function.
+ for(int i = 0; i < 10; i++)
+ std::cout << uni() << '\n';
+
+ /*
+ * Change seed to something else.
+ *
+ * Caveat: std::time(0) is not a very good truly-random seed. When
+ * called in rapid succession, it could return the same values, and
+ * thus the same random number sequences could ensue. If not the same
+ * values are returned, the values differ only slightly in the
+ * lowest bits. A linear congruential generator with a small factor
+ * wrapped in a uniform_smallint (see experiment) will produce the same
+ * values for the first few iterations. This is because uniform_smallint
+ * takes only the highest bits of the generator, and the generator itself
+ * needs a few iterations to spread the initial entropy from the lowest bits
+ * to the whole state.
+ */
+ generator.seed(static_cast<unsigned int>(std::time(0)));
+
+ std::cout << "\nexperiment: roll a die 10 times:\n";
+
+ // You can save a generator's state by copy construction.
+ base_generator_type saved_generator = generator;
+
+ // When calling other functions which take a generator or distribution
+ // as a parameter, make sure to always call by reference (or pointer).
+ // Calling by value invokes the copy constructor, which means that the
+ // sequence of random numbers at the caller is disconnected from the
+ // sequence at the callee.
+ experiment(generator);
+
+ std::cout << "redo the experiment to verify it:\n";
+ experiment(saved_generator);
+
+ // After that, both generators are equivalent
+ assert(generator == saved_generator);
+
+ // as a degenerate case, you can set min = max for uniform_int
+ boost::uniform_int<> degen_dist(4,4);
+ boost::variate_generator<base_generator_type&, boost::uniform_int<> > deg(generator, degen_dist);
+ std::cout << deg() << " " << deg() << " " << deg() << std::endl;
+
+ {
+ // You can save the generator state for future use. You can read the
+ // state back in at any later time using operator>>.
+ std::ofstream file("rng.saved", std::ofstream::trunc);
+ file << generator;
+ }
+
+ return 0;
+}
diff --git a/src/boost/libs/random/example/weighted_die.cpp b/src/boost/libs/random/example/weighted_die.cpp
new file mode 100644
index 000000000..8dd9c2ac7
--- /dev/null
+++ b/src/boost/libs/random/example/weighted_die.cpp
@@ -0,0 +1,55 @@
+// weighted_die.cpp
+//
+// Copyright (c) 2009
+// Steven Watanabe
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+//[weighted_die
+/*`
+ For the source of this example see
+ [@boost://libs/random/example/weighted_die.cpp weighted_die.cpp].
+*/
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/discrete_distribution.hpp>
+
+boost::mt19937 gen;
+
+/*`
+ This time, instead of a fair die, the probability of
+ rolling a 1 is 50% (!). The other five faces are all
+ equally likely.
+
+ __discrete_distribution works nicely here by allowing
+ us to assign weights to each of the possible outcomes.
+
+ [tip If your compiler supports `std::initializer_list`,
+ you can initialize __discrete_distribution directly with
+ the weights.]
+*/
+double probabilities[] = {
+ 0.5, 0.1, 0.1, 0.1, 0.1, 0.1
+};
+boost::random::discrete_distribution<> dist(probabilities);
+
+/*`
+ Now define a function that simulates rolling this die.
+*/
+int roll_weighted_die() {
+ /*<< Add 1 to make sure that the result is in the range [1,6]
+ instead of [0,5].
+ >>*/
+ return dist(gen) + 1;
+}
+
+//]
+
+#include <iostream>
+
+int main() {
+ for(int i = 0; i < 10; ++i) {
+ std::cout << roll_weighted_die() << std::endl;
+ }
+}
diff --git a/src/boost/libs/random/extra/Jamfile.v2 b/src/boost/libs/random/extra/Jamfile.v2
new file mode 100644
index 000000000..a0ee2af3b
--- /dev/null
+++ b/src/boost/libs/random/extra/Jamfile.v2
@@ -0,0 +1,10 @@
+# Jamfile.v2
+#
+# Copyright (c) 2009
+# Steven Watanabe
+#
+# Distributed under the Boost Software License, Version 1.0 (See
+# accompanying file LICENSE_1_0.txt or copy at
+# http://www.boost.org/LICENSE_1_0.txt)
+
+run test_haertel.cpp ;
diff --git a/src/boost/libs/random/extra/haertel.hpp b/src/boost/libs/random/extra/haertel.hpp
new file mode 100644
index 000000000..c318d805b
--- /dev/null
+++ b/src/boost/libs/random/extra/haertel.hpp
@@ -0,0 +1,156 @@
+/* haertel.hpp file
+ *
+ * Copyright Jens Maurer 2000, 2002
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ * Revision history
+ */
+
+/*
+ * NOTE: This is not part of the official boost submission. It exists
+ * only as a collection of ideas.
+ */
+
+#ifndef BOOST_RANDOM_HAERTEL_HPP
+#define BOOST_RANDOM_HAERTEL_HPP
+
+#include <boost/cstdint.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/inversive_congruential.hpp>
+
+namespace boost {
+namespace random {
+
+// Wikramaratna 1989 ACORN
+template<class IntType, int k, IntType m, IntType val>
+class additive_congruential
+{
+public:
+ typedef IntType result_type;
+#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
+ static const bool has_fixed_range = true;
+ static const result_type min_value = 0;
+ static const result_type max_value = m-1;
+#else
+ enum {
+ has_fixed_range = true,
+ min_value = 0,
+ max_value = m-1
+ };
+#endif
+ template<class InputIterator>
+ explicit additive_congruential(InputIterator start) { seed(start); }
+ template<class InputIterator>
+ void seed(InputIterator start)
+ {
+ for(int i = 0; i <= k; ++i, ++start)
+ values[i] = *start;
+ }
+
+ result_type operator()()
+ {
+ for(int i = 1; i <= k; ++i) {
+ IntType tmp = values[i-1] + values[i];
+ if(tmp >= m)
+ tmp -= m;
+ values[i] = tmp;
+ }
+ return values[k];
+ }
+ result_type validation() const { return val; }
+private:
+ IntType values[k+1];
+};
+
+
+template<class IntType, int r, int s, IntType m, IntType val>
+class lagged_fibonacci_int
+{
+public:
+ typedef IntType result_type;
+#ifndef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
+ static const bool has_fixed_range = true;
+ static const result_type min_value = 0;
+ static const result_type max_value = m-1;
+#else
+ enum {
+ has_fixed_range = true,
+ min_value = 0,
+ max_value = m-1
+ };
+#endif
+ explicit lagged_fibonacci_int(IntType start) { seed(start); }
+ template<class Generator>
+ explicit lagged_fibonacci_int(Generator & gen) { seed(gen); }
+ void seed(IntType start)
+ {
+ linear_congruential<uint32_t, 299375077, 0, 0, 0> init;
+ seed(init);
+ }
+ template<class Generator>
+ void seed(Generator & gen)
+ {
+ assert(r > s);
+ for(int i = 0; i < 607; ++i)
+ values[i] = gen();
+ current = 0;
+ lag = r-s;
+ }
+
+ result_type operator()()
+ {
+ result_type tmp = values[current] + values[lag];
+ if(tmp >= m)
+ tmp -= m;
+ values[current] = tmp;
+ ++current;
+ if(current >= r)
+ current = 0;
+ ++lag;
+ if(lag >= r)
+ lag = 0;
+ return tmp;
+ }
+ result_type validation() const { return val; }
+private:
+ result_type values[r];
+ int current, lag;
+};
+
+} // namespace random
+} // namespace boost
+
+// distributions from Haertel's dissertation
+// (additional parameterizations of the basic templates)
+namespace Haertel {
+ typedef boost::random::linear_congruential<boost::uint64_t, 45965, 453816691,
+ (boost::uint64_t(1)<<31), 0> LCG_Af2;
+ typedef boost::random::linear_congruential<boost::uint64_t, 211936855, 0,
+ (boost::uint64_t(1)<<29)-3, 0> LCG_Die1;
+ typedef boost::random::linear_congruential<boost::uint32_t, 2824527309u, 0,
+ 0, 0> LCG_Fis;
+ typedef boost::random::linear_congruential<boost::uint64_t, 950706376u, 0,
+ (boost::uint64_t(1)<<31)-1, 0> LCG_FM;
+ typedef boost::random::linear_congruential<boost::int32_t, 51081, 0,
+ 2147483647, 0> LCG_Hae;
+ typedef boost::random::linear_congruential<boost::uint32_t, 69069, 1,
+ 0, 0> LCG_VAX;
+ typedef boost::random::inversive_congruential<boost::int64_t, 240318, 197,
+ 1000081, 0> NLG_Inv1;
+ typedef boost::random::inversive_congruential<boost::int64_t, 15707262,
+ 13262967, (1<<24)-17, 0> NLG_Inv2;
+ typedef boost::random::inversive_congruential<boost::int32_t, 1, 1,
+ 2147483647, 0> NLG_Inv4;
+ typedef boost::random::inversive_congruential<boost::int32_t, 1, 2,
+ 1<<30, 0> NLG_Inv5;
+ typedef boost::random::additive_congruential<boost::int32_t, 6,
+ (1<<30)-35, 0> MRG_Acorn7;
+ typedef boost::random::lagged_fibonacci_int<boost::uint32_t, 607, 273,
+ 0, 0> MRG_Fib2;
+} // namespace Haertel
+
+#endif
diff --git a/src/boost/libs/random/extra/test_haertel.cpp b/src/boost/libs/random/extra/test_haertel.cpp
new file mode 100644
index 000000000..e5beb265e
--- /dev/null
+++ b/src/boost/libs/random/extra/test_haertel.cpp
@@ -0,0 +1,62 @@
+/* haertel.hpp file
+ *
+ * Copyright Jens Maurer 2000, 2002
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ * Revision history
+ */
+
+#include <string>
+#include <iostream>
+
+#include <boost/format.hpp>
+
+#include "haertel.hpp"
+
+#define BOOST_TEST_MAIN
+#include <boost/test/included/unit_test.hpp>
+
+template<class Gen, class T>
+inline void check_validation(Gen & gen, T value, const std::string & name)
+{
+ for(int i = 0; i < 100000-1; ++i)
+ gen();
+
+ typename Gen::result_type actual = gen();
+ BOOST_CHECK_MESSAGE(value == actual,
+ boost::str(boost::format("%s: check value == gen() failed [%d != %d]") %
+ name % value % actual));
+}
+
+// we have validation after 100000 steps with Haertel's generators
+template<class Gen, class T>
+void validate(T value, const std::string & name)
+{
+ Gen gen(1234567);
+ check_validation(gen, value, name);
+}
+
+BOOST_AUTO_TEST_CASE(test_haertel)
+{
+ using namespace Haertel;
+ validate<LCG_Af2>(183269031u, "LCG_Af2");
+ validate<LCG_Die1>(522319944u, "LCG_Die1");
+ validate<LCG_Fis>(-2065162233u, "LCG_Fis");
+ validate<LCG_FM>(581815473u, "LCG_FM");
+ validate<LCG_Hae>(28931709, "LCG_Hae");
+ validate<LCG_VAX>(1508154087u, "LCG_VAX");
+ validate<NLG_Inv2>(6666884, "NLG_Inv2");
+ validate<NLG_Inv4>(1521640076, "NLG_Inv4");
+ validate<NLG_Inv5>(641840839, "NLG_Inv5");
+ static const int acorn7_init[]
+ = { 1234567, 7654321, 246810, 108642, 13579, 97531, 555555 };
+ MRG_Acorn7 acorn7(acorn7_init);
+ check_validation(acorn7, 874294697, "MRG_Acorn7");
+ // This currently fails. I don't want to touch it until
+ // I trace the source of this generator. --SJW
+ validate<MRG_Fib2>(1234567u, "MRG_Fib2");
+}
diff --git a/src/boost/libs/random/index.html b/src/boost/libs/random/index.html
new file mode 100644
index 000000000..9c0a8475d
--- /dev/null
+++ b/src/boost/libs/random/index.html
@@ -0,0 +1,14 @@
+<html>
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost_random.html">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost_random.html">../../doc/html/boost_random.html</a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/meta/libraries.json b/src/boost/libs/random/meta/libraries.json
new file mode 100644
index 000000000..ffdd91ca4
--- /dev/null
+++ b/src/boost/libs/random/meta/libraries.json
@@ -0,0 +1,17 @@
+{
+ "key": "random",
+ "name": "Random",
+ "authors": [
+ "Jens Maurer"
+ ],
+ "description": "A complete system for random number generation.",
+ "std": [
+ "tr1"
+ ],
+ "category": [
+ "Math"
+ ],
+ "maintainers": [
+ "Steven Watanabe <watanabesj -at- gmail.com>"
+ ]
+}
diff --git a/src/boost/libs/random/nondet_random.html b/src/boost/libs/random/nondet_random.html
new file mode 100644
index 000000000..d0ae9a8a1
--- /dev/null
+++ b/src/boost/libs/random/nondet_random.html
@@ -0,0 +1,17 @@
+<html>
+ <!-- boostinspect:nounlinked boostinspect:nolink -->
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost/random_device.html">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost/random_device.html">
+ ../../doc/html/boost/random_device.html
+ </a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/performance/Jamfile.v2 b/src/boost/libs/random/performance/Jamfile.v2
new file mode 100644
index 000000000..431538589
--- /dev/null
+++ b/src/boost/libs/random/performance/Jamfile.v2
@@ -0,0 +1,18 @@
+mt19937ar-files = [ glob mt19937ar.c ] ;
+
+if $(mt19937ar-files)
+{
+ alias mt19937ar : $(mt19937ar-files) : : <define>HAVE_MT19937AR_C ;
+}
+else
+{
+ alias mt19937ar ;
+}
+
+exe random_speed.exe : random_speed.cpp mt19937ar : release ;
+exe generate_table.exe : generate_table.cpp /boost//regex : <link>static ;
+exe nondet_random_speed.exe : nondet_random_speed.cpp /boost//random : release <link>static ;
+
+install random_speed : random_speed.exe : <install-type>EXE <location>. ;
+install nondet_random_speed : nondet_random_speed.exe : <install-type>EXE <location>. ;
+install generate_table : generate_table.exe : <install-type>EXE <location>. ;
diff --git a/src/boost/libs/random/performance/generate_table.cpp b/src/boost/libs/random/performance/generate_table.cpp
new file mode 100644
index 000000000..c899d08f7
--- /dev/null
+++ b/src/boost/libs/random/performance/generate_table.cpp
@@ -0,0 +1,133 @@
+// generate_table.cpp
+//
+// Copyright (c) 2009
+// Steven Watanabe
+//
+// Distributed under the Boost Software License, Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+#include <vector>
+#include <utility>
+#include <iostream>
+#include <cstring>
+#include <fstream>
+#include <boost/regex.hpp>
+#include <boost/tuple/tuple.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/foreach.hpp>
+#include <boost/format.hpp>
+#include <boost/multi_index_container.hpp>
+#include <boost/multi_index/hashed_index.hpp>
+#include <boost/multi_index/sequenced_index.hpp>
+
+boost::regex generator_regex("(?:fixed-range )?([^:]+): (\\d+(?:\\.\\d+)?) nsec/loop = \\d+(?:\\.\\d+)? CPU cycles");
+boost::regex distribution_regex("([^\\s]+)( virtual function)? ([^:]+): (\\d+(?:\\.\\d+)?) nsec/loop = \\d+(?:\\.\\d+)? CPU cycles");
+
+std::string template_name(std::string arg) {
+ return boost::regex_replace(arg, boost::regex("[^\\w]"), "_");
+}
+
+struct compare_second {
+ template<class Pair>
+ bool operator()(const Pair& p1, const Pair& p2) const {
+ return (p1.second < p2.second);
+ }
+};
+
+typedef boost::multi_index_container<
+ std::string,
+ boost::mpl::vector<
+ boost::multi_index::sequenced<>,
+ boost::multi_index::hashed_unique<boost::multi_index::identity<std::string> >
+ >
+> unique_list;
+
+int main(int argc, char** argv) {
+
+ std::string suffix;
+ std::string id;
+
+ if(argc >= 2 && std::strcmp(argv[1], "-linux") == 0) {
+ suffix = "linux";
+ id = "Linux";
+ } else {
+ suffix = "windows";
+ id = "Windows";
+ }
+
+ std::vector<std::pair<std::string, double> > generator_info;
+ std::string line;
+ while(std::getline(std::cin, line)) {
+ boost::smatch match;
+ if(std::strncmp(line.c_str(), "counting ", 9) == 0) break;
+ if(boost::regex_match(line, match, generator_regex)) {
+ std::string generator(match[1]);
+ double time = boost::lexical_cast<double>(match[2]);
+ if(generator != "counting") {
+ generator_info.push_back(std::make_pair(generator, time));
+ }
+ } else {
+ std::cerr << "oops: " << line << std::endl;
+ }
+ }
+
+ double min = std::min_element(generator_info.begin(), generator_info.end(), compare_second())->second;
+
+ std::ofstream generator_defs("performance_data.qbk");
+ std::ofstream generator_performance(("generator_performance_" + suffix + ".qbk").c_str());
+ generator_performance << "[table Basic Generators (" << id << ")\n";
+ generator_performance << " [[generator] [M rn/sec] [time per random number \\[nsec\\]] "
+ "[relative speed compared to fastest \\[percent\\]]]\n";
+
+ typedef std::pair<std::string, double> pair_type;
+ BOOST_FOREACH(const pair_type& pair, generator_info) {
+ generator_defs << boost::format("[template %s_speed[] %d%%]\n")
+ % template_name(pair.first) % static_cast<int>(100*min/pair.second);
+ generator_performance << boost::format(" [[%s][%g][%g][%d%%]]\n")
+ % pair.first % (1000/pair.second) % pair.second % static_cast<int>(100*min/pair.second);
+ }
+ generator_performance << "]\n";
+
+ std::map<std::pair<std::string, std::string>, double> distribution_info;
+ unique_list generator_names;
+ unique_list distribution_names;
+ do {
+ boost::smatch match;
+ if(boost::regex_match(line, match, distribution_regex)) {
+ if(!match[2].matched && match[1] != "counting") {
+ std::string generator(match[1]);
+ std::string distribution(match[3]);
+ double time = boost::lexical_cast<double>(match[4]);
+ generator_names.push_back(generator);
+ distribution_names.push_back(distribution);
+ distribution_info.insert(std::make_pair(std::make_pair(distribution, generator), time));
+ }
+ } else {
+ std::cerr << "oops: " << line << std::endl;
+ }
+ } while(std::getline(std::cin, line));
+
+ std::ofstream distribution_performance(("distribution_performance_" + suffix + ".qbk").c_str());
+
+ distribution_performance << "[table Distributions (" << id << ")\n";
+ distribution_performance << " [[\\[M rn/sec\\]]";
+ BOOST_FOREACH(const std::string& generator, generator_names) {
+ distribution_performance << boost::format("[%s]") % generator;
+ }
+ distribution_performance << "]\n";
+ BOOST_FOREACH(const std::string& distribution, distribution_names) {
+ distribution_performance << boost::format(" [[%s]") % distribution;
+ BOOST_FOREACH(const std::string& generator, generator_names) {
+ std::map<std::pair<std::string, std::string>, double>::iterator pos =
+ distribution_info.find(std::make_pair(distribution, generator));
+ if(pos != distribution_info.end()) {
+ distribution_performance << boost::format("[%g]") % (1000/pos->second);
+ } else {
+ distribution_performance << "[-]";
+ }
+ }
+ distribution_performance << "]\n";
+ }
+ distribution_performance << "]\n";
+}
diff --git a/src/boost/libs/random/performance/nondet_random_speed.cpp b/src/boost/libs/random/performance/nondet_random_speed.cpp
new file mode 100644
index 000000000..bf45a08bd
--- /dev/null
+++ b/src/boost/libs/random/performance/nondet_random_speed.cpp
@@ -0,0 +1,60 @@
+/* boost nondet_random_speed.cpp performance test
+ *
+ * Copyright Jens Maurer 2000
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <iostream>
+#include <string>
+#include <boost/timer.hpp>
+#include <boost/random/random_device.hpp>
+
+// set to your CPU frequency
+static const double cpu_frequency = 1.87 * 1e9;
+
+static void show_elapsed(double end, int iter, const std::string & name)
+{
+ double usec = end/iter*1e6;
+ double cycles = usec * cpu_frequency/1e6;
+ std::cout << name << ": "
+ << usec*1e3 << " nsec/loop = "
+ << cycles << " CPU cycles"
+ << std::endl;
+}
+
+template<class Result, class RNG>
+static void timing(RNG & rng, int iter, const std::string& name)
+{
+ volatile Result tmp; // make sure we're not optimizing too much
+ boost::timer t;
+ for(int i = 0; i < iter; i++)
+ tmp = rng();
+ show_elapsed(t.elapsed(), iter, name);
+}
+
+template<class RNG>
+void run(int iter, const std::string & name)
+{
+ RNG rng;
+ timing<long>(rng, iter, name);
+}
+
+int main(int argc, char*argv[])
+{
+ if(argc != 2) {
+ std::cerr << "usage: " << argv[0] << " iterations" << std::endl;
+ return 1;
+ }
+
+ int iter = std::atoi(argv[1]);
+
+ boost::random::random_device dev;
+ timing<unsigned int>(dev, iter, "random_device");
+
+ return 0;
+}
diff --git a/src/boost/libs/random/performance/random_speed.cpp b/src/boost/libs/random/performance/random_speed.cpp
new file mode 100644
index 000000000..aac9ab5ae
--- /dev/null
+++ b/src/boost/libs/random/performance/random_speed.cpp
@@ -0,0 +1,399 @@
+/* boost random_speed.cpp performance measurements
+ *
+ * Copyright Jens Maurer 2000
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ */
+
+#include <iostream>
+#include <cstdlib>
+#include <string>
+#include <boost/config.hpp>
+#include <boost/random.hpp>
+#include <boost/progress.hpp>
+#include <boost/shared_ptr.hpp>
+
+/*
+ * Configuration Section
+ */
+
+// define if your C library supports the non-standard drand48 family
+//#define HAVE_DRAND48
+
+// define if you have the original mt19937int.c (with commented out main())
+#undef HAVE_MT19937INT_C
+
+// define if you have the original mt19937ar.c (with commented out main())
+// #define HAVE_MT19937AR_C
+
+// set to your CPU frequency
+static const double cpu_frequency = 1.87 * 1e9;
+
+/*
+ * End of Configuration Section
+ */
+
+/*
+ * General portability note:
+ * MSVC mis-compiles explicit function template instantiations.
+ * For example, f<A>() and f<B>() are both compiled to call f<A>().
+ * BCC is unable to implicitly convert a "const char *" to a std::string
+ * when using explicit function template instantiations.
+ *
+ * Therefore, avoid explicit function template instantiations.
+ */
+
+// provides a run-time configurable linear congruential generator, just
+// for comparison
+template<class IntType>
+class linear_congruential
+{
+public:
+ typedef IntType result_type;
+
+ BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
+
+ linear_congruential(IntType x0, IntType a, IntType c, IntType m)
+ : _x(x0), _a(a), _c(c), _m(m) { }
+ // compiler-generated copy ctor and assignment operator are fine
+ void seed(IntType x0, IntType a, IntType c, IntType m)
+ { _x = x0; _a = a; _c = c; _m = m; }
+ void seed(IntType x0) { _x = x0; }
+ result_type operator()() { _x = (_a*_x+_c) % _m; return _x; }
+ result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _c == 0 ? 1 : 0; }
+ result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return _m -1; }
+
+private:
+ IntType _x, _a, _c, _m;
+};
+
+
+// simplest "random" number generator possible, to check on overhead
+class counting
+{
+public:
+ typedef int result_type;
+
+ BOOST_STATIC_CONSTANT(bool, has_fixed_range = false);
+
+ counting() : _x(0) { }
+ result_type operator()() { return ++_x; }
+ result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 1; }
+ result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return (std::numeric_limits<result_type>::max)(); }
+
+private:
+ int _x;
+};
+
+
+// decoration of variate_generator to make it runtime-exchangeable
+// for speed comparison
+template<class Ret>
+class RandomGenBase
+{
+public:
+ virtual Ret operator()() = 0;
+ virtual ~RandomGenBase() { }
+};
+
+template<class URNG, class Dist, class Ret = typename Dist::result_type>
+class DynamicRandomGenerator
+ : public RandomGenBase<Ret>
+{
+public:
+ DynamicRandomGenerator(URNG& urng, const Dist& d) : _rng(urng, d) { }
+ Ret operator()() { return _rng(); }
+private:
+ boost::variate_generator<URNG&, Dist> _rng;
+};
+
+template<class Ret>
+class GenericRandomGenerator
+{
+public:
+ typedef Ret result_type;
+
+ GenericRandomGenerator() { };
+ void set(boost::shared_ptr<RandomGenBase<Ret> > p) { _p = p; }
+ // takes over ownership
+ void set(RandomGenBase<Ret> * p) { _p.reset(p); }
+ Ret operator()() { return (*_p)(); }
+private:
+ boost::shared_ptr<RandomGenBase<Ret> > _p;
+};
+
+
+// start implementation of measuring timing
+
+void show_elapsed(double end, int iter, const std::string & name)
+{
+ double usec = end/iter*1e6;
+ double cycles = usec * cpu_frequency/1e6;
+ std::cout << name << ": "
+ << usec*1e3 << " nsec/loop = "
+ << cycles << " CPU cycles"
+ << std::endl;
+}
+
+#if 0
+template<class RNG>
+void timing(RNG & rng, int iter, const std::string& name)
+{
+ // make sure we're not optimizing too much
+ volatile typename RNG::result_type tmp;
+ boost::timer t;
+ for(int i = 0; i < iter; i++)
+ tmp = rng();
+ show_elapsed(t.elapsed(), iter, name);
+}
+#endif
+
+// overload for using a copy, allows more concise invocation
+template<class RNG>
+void timing(RNG rng, int iter, const std::string& name)
+{
+ // make sure we're not optimizing too much
+ volatile typename RNG::result_type tmp;
+ boost::timer t;
+ for(int i = 0; i < iter; i++)
+ tmp = rng();
+ show_elapsed(t.elapsed(), iter, name);
+}
+
+template<class RNG>
+void timing_sphere(RNG rng, int iter, const std::string & name)
+{
+ boost::timer t;
+ for(int i = 0; i < iter; i++) {
+ // the special return value convention of uniform_on_sphere saves 20% CPU
+ const std::vector<double> & tmp = rng();
+ (void) tmp[0];
+ }
+ show_elapsed(t.elapsed(), iter, name);
+}
+
+template<class RNG>
+void run(int iter, const std::string & name, RNG rng)
+{
+ std::cout << (RNG::has_fixed_range ? "fixed-range " : "");
+ // BCC has trouble with string autoconversion for explicit specializations
+
+ // make sure we're not optimizing too much
+ volatile typename RNG::result_type tmp;
+ boost::timer t;
+ for(int i = 0; i < iter; i++)
+ tmp = rng();
+ show_elapsed(t.elapsed(), iter, name);
+}
+
+#ifdef HAVE_DRAND48
+// requires non-standard C library support for srand48/lrand48
+struct lrand48_ {
+ static const bool has_fixed_range = false;
+ typedef long result_type;
+ lrand48_() {
+ using namespace std;
+ srand48(1);
+ }
+ result_type operator()() {
+ using namespace std;
+ return lrand48();
+ }
+};
+#endif
+
+#ifdef HAVE_MT19937INT_C // requires the original mt19937int.c
+extern "C" void sgenrand(unsigned long);
+extern "C" unsigned long genrand();
+
+void run(int iter, const std::string & name, float)
+{
+ sgenrand(4357);
+ timing(genrand, iter, name, 0u);
+}
+#endif
+
+#ifdef HAVE_MT19937AR_C
+extern "C" {
+void init_genrand(unsigned long s);
+unsigned long genrand_int32(void);
+}
+struct mt19937_c {
+ static const bool has_fixed_range = false;
+ mt19937_c() {
+ init_genrand(5489);
+ }
+ typedef unsigned long result_type;
+ result_type operator()() {
+ return genrand_int32();
+ }
+};
+#endif
+
+template<class PRNG, class Dist>
+inline boost::variate_generator<PRNG&, Dist> make_gen(PRNG & rng, Dist d)
+{
+ return boost::variate_generator<PRNG&, Dist>(rng, d);
+}
+
+template<class Gen>
+void distrib(int iter, const std::string & name, const Gen &)
+{
+ Gen gen;
+
+ timing(make_gen(gen, boost::random::uniform_int_distribution<>(-2, 4)),
+ iter, name + " uniform_int");
+
+ timing(make_gen(gen, boost::random::uniform_smallint<>(-2, 4)),
+ iter, name + " uniform_smallint");
+
+ timing(make_gen(gen, boost::random::bernoulli_distribution<>(0.5)),
+ iter, name + " bernoulli");
+
+ timing(make_gen(gen, boost::random::geometric_distribution<>(0.5)),
+ iter, name + " geometric");
+
+ timing(make_gen(gen, boost::random::binomial_distribution<int>(4, 0.8)),
+ iter, name + " binomial");
+
+ timing(make_gen(gen, boost::random::negative_binomial_distribution<int>(4, 0.8)),
+ iter, name + " negative_binomial");
+
+ timing(make_gen(gen, boost::random::poisson_distribution<>(1)),
+ iter, name + " poisson");
+
+
+ timing(make_gen(gen, boost::random::uniform_real_distribution<>(-5.3, 4.8)),
+ iter, name + " uniform_real");
+
+ timing(make_gen(gen, boost::random::uniform_01<>()),
+ iter, name + " uniform_01");
+
+ timing(make_gen(gen, boost::random::triangle_distribution<>(1, 2, 7)),
+ iter, name + " triangle");
+
+ timing(make_gen(gen, boost::random::exponential_distribution<>(3)),
+ iter, name + " exponential");
+
+ timing(make_gen(gen, boost::random::normal_distribution<>()),
+ iter, name + " normal polar");
+
+ timing(make_gen(gen, boost::random::lognormal_distribution<>()),
+ iter, name + " lognormal");
+
+ timing(make_gen(gen, boost::random::chi_squared_distribution<>(4)),
+ iter, name + " chi squared");
+
+ timing(make_gen(gen, boost::random::cauchy_distribution<>()),
+ iter, name + " cauchy");
+
+ timing(make_gen(gen, boost::random::fisher_f_distribution<>(4, 5)),
+ iter, name + " fisher f");
+
+ timing(make_gen(gen, boost::random::student_t_distribution<>(7)),
+ iter, name + " student t");
+
+ timing(make_gen(gen, boost::random::gamma_distribution<>(2.8)),
+ iter, name + " gamma");
+
+ timing(make_gen(gen, boost::random::weibull_distribution<>(3)),
+ iter, name + " weibull");
+
+ timing(make_gen(gen, boost::random::extreme_value_distribution<>()),
+ iter, name + " extreme value");
+
+ timing_sphere(make_gen(gen, boost::random::uniform_on_sphere<>(3)),
+ iter/10, name + " uniform_on_sphere");
+}
+
+int main(int argc, char*argv[])
+{
+ if(argc != 2) {
+ std::cerr << "usage: " << argv[0] << " iterations" << std::endl;
+ return 1;
+ }
+
+ // okay, it's ugly, but it's only used here
+ int iter =
+#ifndef BOOST_NO_STDC_NAMESPACE
+ std::
+#endif
+ atoi(argv[1]);
+
+#if !defined(BOOST_NO_INT64_T) && \
+ !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION)
+ run(iter, "rand48", boost::rand48());
+ linear_congruential<boost::uint64_t>
+ lcg48(boost::uint64_t(1)<<16 | 0x330e,
+ boost::uint64_t(0xDEECE66DUL) | (boost::uint64_t(0x5) << 32), 0xB,
+ boost::uint64_t(1)<<48);
+ timing(lcg48, iter, "lrand48 run-time");
+#endif
+
+#ifdef HAVE_DRAND48
+ // requires non-standard C library support for srand48/lrand48
+ run(iter, "lrand48", lrand48_()); // coded for lrand48()
+#endif
+
+ run(iter, "minstd_rand0", boost::minstd_rand0());
+ run(iter, "minstd_rand", boost::minstd_rand());
+ run(iter, "ecuyer combined", boost::ecuyer1988());
+ run(iter, "kreutzer1986", boost::kreutzer1986());
+ run(iter, "taus88", boost::taus88());
+ run(iter, "knuth_b", boost::random::knuth_b());
+
+ run(iter, "hellekalek1995 (inversive)", boost::hellekalek1995());
+
+ run(iter, "mt11213b", boost::mt11213b());
+ run(iter, "mt19937", boost::mt19937());
+#if !defined(BOOST_NO_INT64_T)
+ run(iter, "mt19937_64", boost::mt19937_64());
+#endif
+
+ run(iter, "lagged_fibonacci607", boost::lagged_fibonacci607());
+ run(iter, "lagged_fibonacci1279", boost::lagged_fibonacci1279());
+ run(iter, "lagged_fibonacci2281", boost::lagged_fibonacci2281());
+ run(iter, "lagged_fibonacci3217", boost::lagged_fibonacci3217());
+ run(iter, "lagged_fibonacci4423", boost::lagged_fibonacci4423());
+ run(iter, "lagged_fibonacci9689", boost::lagged_fibonacci9689());
+ run(iter, "lagged_fibonacci19937", boost::lagged_fibonacci19937());
+ run(iter, "lagged_fibonacci23209", boost::lagged_fibonacci23209());
+ run(iter, "lagged_fibonacci44497", boost::lagged_fibonacci44497());
+
+ run(iter, "subtract_with_carry", boost::random::ranlux_base());
+ run(iter, "subtract_with_carry_01", boost::random::ranlux_base_01());
+ run(iter, "ranlux3", boost::ranlux3());
+ run(iter, "ranlux4", boost::ranlux4());
+ run(iter, "ranlux3_01", boost::ranlux3_01());
+ run(iter, "ranlux4_01", boost::ranlux4_01());
+ run(iter, "ranlux64_3", boost::ranlux3());
+ run(iter, "ranlux64_4", boost::ranlux4());
+ run(iter, "ranlux64_3_01", boost::ranlux3_01());
+ run(iter, "ranlux64_4_01", boost::ranlux4_01());
+ run(iter, "ranlux24", boost::ranlux3());
+ run(iter, "ranlux48", boost::ranlux4());
+
+ run(iter, "counting", counting());
+
+#ifdef HAVE_MT19937INT_C
+ // requires the original mt19937int.c
+ run<float>(iter, "mt19937 original"); // coded for sgenrand()/genrand()
+#endif
+
+#ifdef HAVE_MT19937AR_C
+ run(iter, "mt19937ar.c", mt19937_c());
+#endif
+
+ distrib(iter, "counting", counting());
+
+ distrib(iter, "minstd_rand", boost::minstd_rand());
+
+ distrib(iter, "kreutzer1986", boost::kreutzer1986());
+
+ distrib(iter, "mt19937", boost::mt19937());
+
+ distrib(iter, "lagged_fibonacci607", boost::lagged_fibonacci607());
+}
diff --git a/src/boost/libs/random/random-concepts.html b/src/boost/libs/random/random-concepts.html
new file mode 100644
index 000000000..aea420b19
--- /dev/null
+++ b/src/boost/libs/random/random-concepts.html
@@ -0,0 +1,17 @@
+<html>
+ <!-- boostinspect:nounlinked boostinspect:nolink -->
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost_random/reference.html#boost_random.reference.concepts">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost_random/reference.html#boost_random.reference.concepts">
+ ../../doc/html/boost_random/reference.html#boost_random.reference.concepts
+ </a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/random-distributions.html b/src/boost/libs/random/random-distributions.html
new file mode 100644
index 000000000..605bfa69d
--- /dev/null
+++ b/src/boost/libs/random/random-distributions.html
@@ -0,0 +1,17 @@
+<html>
+ <!-- boostinspect:nounlinked boostinspect:nolink -->
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost_random/reference.html#boost_random.reference.distributions">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost_random/reference.html#boost_random.reference.distributions">
+ ../../doc/html/boost_random/reference.html#boost_random.reference.distributions
+ </a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/random-generators.html b/src/boost/libs/random/random-generators.html
new file mode 100644
index 000000000..1872c4097
--- /dev/null
+++ b/src/boost/libs/random/random-generators.html
@@ -0,0 +1,17 @@
+<html>
+ <!-- boostinspect:nounlinked boostinspect:nolink -->
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost_random/reference.html#boost_random.reference.generators">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost_random/reference.html#boost_random.reference.generators">
+ ../../doc/html/boost_random/reference.html#boost_random.reference.generators
+ </a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/random-misc.html b/src/boost/libs/random/random-misc.html
new file mode 100644
index 000000000..5b319904b
--- /dev/null
+++ b/src/boost/libs/random/random-misc.html
@@ -0,0 +1,17 @@
+<html>
+ <!-- boostinspect:nounlinked boostinspect:nolink -->
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost/random_number_generator.html">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost/random_number_generator.html">
+ ../../doc/html/boost/random_number_generator.html
+ </a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/random-performance.html b/src/boost/libs/random/random-performance.html
new file mode 100644
index 000000000..6cbef8dea
--- /dev/null
+++ b/src/boost/libs/random/random-performance.html
@@ -0,0 +1,17 @@
+<html>
+ <!-- boostinspect:nounlinked boostinspect:nolink -->
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost_random/performance.html">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost_random/performance.html">
+ ../../doc/html/boost_random/performance.html
+ </a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/random-variate.html b/src/boost/libs/random/random-variate.html
new file mode 100644
index 000000000..a5d931fee
--- /dev/null
+++ b/src/boost/libs/random/random-variate.html
@@ -0,0 +1,17 @@
+<html>
+ <!-- boostinspect:nounlinked boostinspect:nolink -->
+ <head>
+ <meta http-equiv="refresh" content="0; URL=../../doc/html/boost/variate_generator.html">
+ </head>
+ <body>
+ Automatic redirection failed, please go to
+ <a href="../../doc/html/boost/variate_generator.html">
+ ../../doc/html/boost/variate_generator.html
+ </a>
+ <p>Copyright (c) 2010 Steven Watanabe</p>
+ <p>Distributed under the Boost Software License, Version 1.0. (See accompanying file
+ <a href="../../LICENSE_1_0.txt">LICENSE_1_0.txt</a> or copy at
+ <a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a>).
+ </p>
+ </body>
+</html>
diff --git a/src/boost/libs/random/src/random_device.cpp b/src/boost/libs/random/src/random_device.cpp
new file mode 100644
index 000000000..8ec386310
--- /dev/null
+++ b/src/boost/libs/random/src/random_device.cpp
@@ -0,0 +1,250 @@
+/* boost random_device.cpp implementation
+ *
+ * Copyright Jens Maurer 2000
+ * Copyright Steven Watanabe 2010-2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#define BOOST_RANDOM_SOURCE
+
+#include <boost/random/random_device.hpp>
+#include <boost/config.hpp>
+#include <boost/throw_exception.hpp>
+#include <boost/assert.hpp>
+#include <boost/detail/workaround.hpp>
+#include <boost/system/system_error.hpp>
+#include <boost/system/error_code.hpp>
+#include <string>
+
+#if !defined(BOOST_NO_INCLASS_MEMBER_INITIALIZATION) && !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1600))
+// A definition is required even for integral static constants
+const bool boost::random::random_device::has_fixed_range;
+#endif
+
+// WinRT target.
+#if !defined(BOOST_RANDOM_WINDOWS_RUNTIME)
+# if defined(__cplusplus_winrt)
+# include <winapifamily.h>
+# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+# define BOOST_RANDOM_WINDOWS_RUNTIME 1
+# endif
+# endif
+#endif
+
+#if defined(BOOST_WINDOWS)
+
+#if !defined(BOOST_RANDOM_WINDOWS_RUNTIME)
+#include <windows.h>
+#include <wincrypt.h>
+#include <stdexcept> // std::invalid_argument
+#else
+using namespace Platform;
+using namespace Windows::Security::Cryptography;
+#endif
+
+#define BOOST_AUTO_LINK_NOMANGLE
+#define BOOST_LIB_NAME "Advapi32"
+#include <boost/config/auto_link.hpp>
+
+#ifdef __MINGW32__
+
+extern "C" {
+
+// mingw's wincrypt.h appears to be missing some things
+WINADVAPI
+BOOL
+WINAPI
+CryptEnumProvidersA(
+ DWORD dwIndex,
+ DWORD *pdwReserved,
+ DWORD dwFlags,
+ DWORD *pdwProvType,
+ LPSTR szProvName,
+ DWORD *pcbProvName
+ );
+
+}
+
+#endif
+
+namespace {
+#if !defined(BOOST_RANDOM_WINDOWS_RUNTIME)
+const char * const default_token = MS_DEF_PROV_A;
+#else
+const char * const default_token = "";
+#endif
+}
+
+class boost::random::random_device::impl
+{
+public:
+ impl(const std::string & token) : provider(token) {
+#if !defined(BOOST_RANDOM_WINDOWS_RUNTIME)
+ char buffer[80];
+ DWORD type;
+ DWORD len;
+
+ // Find the type of a specific provider
+ for(DWORD i = 0; ; ++i) {
+ len = sizeof(buffer);
+ if(!CryptEnumProvidersA(i, NULL, 0, &type, buffer, &len)) {
+ if (GetLastError() == ERROR_NO_MORE_ITEMS) break;
+ continue;
+ }
+ if(buffer == provider) {
+ break;
+ }
+ }
+
+ if(!CryptAcquireContextA(&hProv, NULL, provider.c_str(), type,
+ CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
+ error("Could not acquire CSP context");
+ }
+#endif
+ }
+
+#if !defined(BOOST_RANDOM_WINDOWS_RUNTIME)
+ ~impl() {
+ if(!CryptReleaseContext(hProv, 0)) error("Could not release CSP context");
+ }
+#endif
+
+ unsigned int next() {
+ unsigned int result;
+
+#if !defined(BOOST_RANDOM_WINDOWS_RUNTIME)
+ if(!CryptGenRandom(hProv, sizeof(result),
+ static_cast<BYTE*>(static_cast<void*>(&result)))) {
+ error("error while reading");
+ }
+#else
+ auto buffer = CryptographicBuffer::GenerateRandom(sizeof(result));
+ auto data = ref new Array<unsigned char>(buffer->Length);
+ CryptographicBuffer::CopyToByteArray(buffer, &data);
+ memcpy(&result, data->begin(), data->end() - data->begin());
+#endif
+
+ return result;
+ }
+
+private:
+#if !defined(BOOST_RANDOM_WINDOWS_RUNTIME)
+ void error(const char * msg) {
+ DWORD error_code = GetLastError();
+ boost::throw_exception(
+ boost::system::system_error(
+ error_code, boost::system::system_category(),
+ std::string("boost::random_device: ") + msg +
+ " Cryptographic Service Provider " + provider));
+ }
+ HCRYPTPROV hProv;
+#endif
+ const std::string provider;
+};
+
+#else
+
+namespace {
+// the default is the unlimited capacity device, using some secure hash
+// try "/dev/random" for blocking when the entropy pool has drained
+const char * const default_token = "/dev/urandom";
+}
+
+/*
+ * This uses the POSIX interface for unbuffered reading.
+ * Using buffered std::istream would consume entropy which may
+ * not actually be used. Entropy is a precious good we avoid
+ * wasting.
+ */
+
+#if defined(__GNUC__) && defined(_CXXRT_STD_NAME)
+// I have severe difficulty to get the POSIX includes to work with
+// -fhonor-std and Dietmar Kuhl's standard C++ library. Hack around that
+// problem for now.
+extern "C" {
+static const int O_RDONLY = 0;
+extern int open(const char *__file, int __oflag, ...);
+extern int read(int __fd, __ptr_t __buf, size_t __nbytes);
+extern int close(int __fd);
+}
+#else
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h> // open
+#include <unistd.h> // read, close
+#endif
+
+#include <errno.h> // errno
+#include <string.h> // strerror
+#include <stdexcept> // std::invalid_argument
+
+
+class boost::random::random_device::impl
+{
+public:
+ impl(const std::string & token) : path(token) {
+ fd = open(token.c_str(), O_RDONLY);
+ if(fd < 0)
+ error("cannot open");
+ }
+
+ ~impl() { if(close(fd) < 0) error("could not close"); }
+
+ unsigned int next() {
+ unsigned int result;
+ std::size_t offset = 0;
+ do {
+ long sz = read(fd, reinterpret_cast<char *>(&result) + offset, sizeof(result) - offset);
+ if(sz == -1)
+ error("error while reading");
+ else if(sz == 0) {
+ errno = 0;
+ error("EOF while reading");
+ }
+ offset += sz;
+ } while(offset < sizeof(result));
+ return result;
+ }
+
+private:
+ void error(const char * msg) {
+ int error_code = errno;
+ boost::throw_exception(
+ boost::system::system_error(
+ error_code, boost::system::system_category(),
+ std::string("boost::random_device: ") + msg +
+ " random-number pseudo-device " + path));
+ }
+ const std::string path;
+ int fd;
+};
+
+#endif // BOOST_WINDOWS
+
+BOOST_RANDOM_DECL boost::random::random_device::random_device()
+ : pimpl(new impl(default_token))
+{}
+
+BOOST_RANDOM_DECL boost::random::random_device::random_device(const std::string& token)
+ : pimpl(new impl(token))
+{}
+
+BOOST_RANDOM_DECL boost::random_device::~random_device()
+{
+ delete pimpl;
+}
+
+BOOST_RANDOM_DECL double boost::random_device::entropy() const
+{
+ return 10;
+}
+
+BOOST_RANDOM_DECL unsigned int boost::random_device::operator()()
+{
+ return pimpl->next();
+}
diff --git a/src/boost/libs/random/test/Jamfile.v2 b/src/boost/libs/random/test/Jamfile.v2
new file mode 100644
index 000000000..13a7643b0
--- /dev/null
+++ b/src/boost/libs/random/test/Jamfile.v2
@@ -0,0 +1,147 @@
+# Copyright 2003 Jens Maurer
+# Copyright 2009-2011 Steven Watanabe
+# Distributed under the Boost Software License, Version 1.0. (See accompany-
+# ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+
+# Boost Random Library test Jamfile
+
+# bring in rules for testing
+import testing ;
+
+project /boost/random/test : requirements <toolset>msvc:<define>_SCL_SECURE_NO_WARNINGS ;
+
+run test_const_mod.cpp /boost//unit_test_framework ;
+run test_generate_canonical.cpp /boost//unit_test_framework ;
+run test_random_number_generator.cpp /boost//unit_test_framework ;
+run ../example/random_demo.cpp ;
+run test_random_device.cpp /boost//random : : : <link>static : test_random_device ;
+run test_random_device.cpp /boost//random : : : <link>shared : test_random_device_dll ;
+
+run test_minstd_rand0.cpp /boost//unit_test_framework ;
+run test_minstd_rand.cpp /boost//unit_test_framework ;
+run test_rand48.cpp /boost//unit_test_framework ;
+run test_mt11213b.cpp /boost//unit_test_framework ;
+run test_mt19937.cpp /boost//unit_test_framework ;
+run test_mt19937_64.cpp /boost//unit_test_framework ;
+run test_ecuyer1988.cpp /boost//unit_test_framework ;
+run test_hellekalek1995.cpp /boost//unit_test_framework ;
+run test_linear_feedback_shift.cpp /boost//unit_test_framework ;
+run test_taus88.cpp /boost//unit_test_framework ;
+run test_kreutzer1986.cpp /boost//unit_test_framework ;
+run test_ranlux3.cpp /boost//unit_test_framework ;
+run test_ranlux4.cpp /boost//unit_test_framework ;
+run test_ranlux3_01.cpp /boost//unit_test_framework ;
+run test_ranlux4_01.cpp /boost//unit_test_framework ;
+run test_ranlux64_4.cpp /boost//unit_test_framework ;
+run test_ranlux64_3.cpp /boost//unit_test_framework ;
+run test_ranlux64_3_01.cpp /boost//unit_test_framework ;
+run test_ranlux64_4_01.cpp /boost//unit_test_framework ;
+run test_ranlux24_base.cpp /boost//unit_test_framework ;
+run test_ranlux24.cpp /boost//unit_test_framework ;
+run test_ranlux48_base.cpp /boost//unit_test_framework ;
+run test_ranlux48.cpp /boost//unit_test_framework ;
+run test_knuth_b.cpp /boost//unit_test_framework ;
+run test_independent_bits31.cpp /boost//unit_test_framework ;
+run test_independent_bits32.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci607.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci1279.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci2281.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci3217.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci4423.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci9689.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci19937.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci23209.cpp /boost//unit_test_framework ;
+run test_lagged_fibonacci44497.cpp /boost//unit_test_framework ;
+run test_zero_seed.cpp /boost//unit_test_framework ;
+
+run niederreiter_base2_validate.cpp /boost//unit_test_framework ;
+run sobol_validate.cpp /boost//unit_test_framework ;
+run faure_validate.cpp /boost//unit_test_framework ;
+
+# Disable by default. These don't add much and the larger
+# ones can overflow the stack.
+explicit test_lagged_fibonacci1279 test_lagged_fibonacci2281
+ test_lagged_fibonacci2281 test_lagged_fibonacci3217
+ test_lagged_fibonacci4423 test_lagged_fibonacci9689
+ test_lagged_fibonacci19937 test_lagged_fibonacci23209
+ test_lagged_fibonacci44497 ;
+
+run test_seed_seq.cpp /boost//unit_test_framework ;
+
+run test_binomial.cpp ;
+run test_binomial_distribution.cpp /boost//unit_test_framework ;
+run test_poisson.cpp ;
+run test_poisson_distribution.cpp /boost//unit_test_framework ;
+run test_discrete.cpp ;
+run test_discrete_distribution.cpp /boost//unit_test_framework ;
+run test_gamma.cpp ;
+run test_gamma_distribution.cpp /boost//unit_test_framework ;
+run test_weibull.cpp ;
+run test_weibull_distribution.cpp /boost//unit_test_framework ;
+run test_extreme_value.cpp ;
+run test_extreme_value_distribution.cpp /boost//unit_test_framework ;
+run test_negative_binomial.cpp ;
+run test_negative_binomial_distribution.cpp /boost//unit_test_framework ;
+run test_chi_squared.cpp ;
+run test_chi_squared_distribution.cpp /boost//unit_test_framework ;
+run test_fisher_f.cpp ;
+run test_fisher_f_distribution.cpp /boost//unit_test_framework ;
+run test_student_t.cpp ;
+run test_student_t_distribution.cpp /boost//unit_test_framework ;
+run test_normal.cpp ;
+run test_normal_distribution.cpp /boost//unit_test_framework ;
+run test_piecewise_constant.cpp ;
+run test_piecewise_constant_distribution.cpp /boost//unit_test_framework ;
+run test_piecewise_linear.cpp ;
+run test_piecewise_linear_distribution.cpp /boost//unit_test_framework ;
+run test_exponential.cpp ;
+run test_exponential_distribution.cpp /boost//unit_test_framework ;
+run test_bernoulli.cpp ;
+run test_bernoulli_distribution.cpp /boost//unit_test_framework ;
+run test_cauchy.cpp ;
+run test_cauchy_distribution.cpp /boost//unit_test_framework ;
+run test_geometric.cpp ;
+run test_geometric_distribution.cpp /boost//unit_test_framework ;
+run test_lognormal.cpp ;
+run test_lognormal_distribution.cpp /boost//unit_test_framework ;
+run test_triangle.cpp ;
+run test_triangle_distribution.cpp /boost//unit_test_framework ;
+run test_uniform_int.cpp ;
+run test_uniform_int_distribution.cpp /boost//unit_test_framework ;
+run test_uniform_real.cpp ;
+run test_uniform_real_distribution.cpp /boost//unit_test_framework ;
+run test_uniform_on_sphere.cpp ;
+run test_uniform_on_sphere_distribution.cpp /boost//unit_test_framework ;
+run test_uniform_smallint.cpp ;
+run test_uniform_smallint_distribution.cpp /boost//unit_test_framework ;
+run test_old_uniform_real.cpp ;
+run test_old_uniform_real_distribution.cpp /boost//unit_test_framework ;
+run test_old_uniform_int.cpp ;
+run test_old_uniform_int_distribution.cpp /boost//unit_test_framework ;
+run test_beta.cpp ;
+run test_beta_distribution.cpp /boost//unit_test_framework ;
+run test_laplace.cpp ;
+run test_laplace_distribution.cpp /boost//unit_test_framework ;
+run test_non_central_chi_squared.cpp ;
+run test_non_central_chi_squared_distribution.cpp /boost//unit_test_framework ;
+run test_hyperexponential.cpp ;
+run test_hyperexponential_distribution.cpp /boost//unit_test_framework ;
+
+# run nondet_random_speed.cpp ;
+# run random_device.cpp ;
+# run random_speed.cpp ;
+# run statistic_tests.cpp ;
+
+exe statistic_tests.exe : statistic_tests.cpp ;
+explicit statistic_tests.exe ;
+
+install statistic_tests : statistic_tests.exe : <install-type>EXE <location>. ;
+explicit statistic_tests ;
+
+#
+# Multiprecision tests:
+#
+run multiprecision_int_test.cpp /boost//unit_test_framework ;
+# This one runs too slow in debug mode, we really need inline expansions turned on amonst other things:
+run multiprecision_float_test.cpp /boost//unit_test_framework : : : release ;
diff --git a/src/boost/libs/random/test/chi_squared_test.hpp b/src/boost/libs/random/test/chi_squared_test.hpp
new file mode 100644
index 000000000..ecf49aad7
--- /dev/null
+++ b/src/boost/libs/random/test/chi_squared_test.hpp
@@ -0,0 +1,92 @@
+/* chi_squared_test.hpp header file
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#ifndef BOOST_RANDOM_TEST_CHI_SQUARED_TEST_HPP_INCLUDED
+#define BOOST_RANDOM_TEST_CHI_SQUARED_TEST_HPP_INCLUDED
+
+#include <vector>
+
+#include <boost/math/special_functions/pow.hpp>
+#include <boost/math/distributions/chi_squared.hpp>
+
+// This only works for discrete distributions with fixed
+// upper and lower bounds.
+
+template<class IntType>
+struct chi_squared_collector {
+
+ static const IntType cutoff = 5;
+
+ chi_squared_collector()
+ : chi_squared(0),
+ variables(0),
+ prev_actual(0),
+ prev_expected(0),
+ current_actual(0),
+ current_expected(0)
+ {}
+
+ void operator()(IntType actual, double expected) {
+ current_actual += actual;
+ current_expected += expected;
+
+ if(current_expected >= cutoff) {
+ if(prev_expected != 0) {
+ update(prev_actual, prev_expected);
+ }
+ prev_actual = current_actual;
+ prev_expected = current_expected;
+
+ current_actual = 0;
+ current_expected = 0;
+ }
+ }
+
+ void update(IntType actual, double expected) {
+ chi_squared += boost::math::pow<2>(actual - expected) / expected;
+ ++variables;
+ }
+
+ double cdf() {
+ if(prev_expected != 0) {
+ update(prev_actual + current_actual, prev_expected + current_expected);
+ prev_actual = 0;
+ prev_expected = 0;
+ current_actual = 0;
+ current_expected = 0;
+ }
+ if(variables <= 1) {
+ return 0;
+ } else {
+ return boost::math::cdf(boost::math::chi_squared(static_cast<double>(variables - 1)), chi_squared);
+ }
+ }
+
+ double chi_squared;
+ std::size_t variables;
+
+ IntType prev_actual;
+ double prev_expected;
+
+ IntType current_actual;
+ double current_expected;
+};
+
+template<class IntType>
+double chi_squared_test(const std::vector<IntType>& results, const std::vector<double>& probabilities, IntType iterations) {
+ chi_squared_collector<IntType> calc;
+ for(std::size_t i = 0; i < results.size(); ++i) {
+ calc(results[i], iterations * probabilities[i]);
+ }
+ return calc.cdf();
+}
+
+#endif
diff --git a/src/boost/libs/random/test/concepts.hpp b/src/boost/libs/random/test/concepts.hpp
new file mode 100644
index 000000000..f9bd75321
--- /dev/null
+++ b/src/boost/libs/random/test/concepts.hpp
@@ -0,0 +1,210 @@
+/* concepts.hpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#ifndef BOOST_RANDOM_TEST_CONCEPTS_HPP
+#define BOOST_RANDOM_TEST_CONCEPTS_HPP
+
+#include <boost/config.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4100)
+#endif
+
+#include <boost/concept_check.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#include <boost/concept_archetype.hpp>
+#include <boost/concept/requires.hpp>
+#include <boost/mpl/assert.hpp>
+#include <boost/type_traits/is_arithmetic.hpp>
+#include <boost/type_traits/is_integral.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/static_assert.hpp>
+#include <istream>
+#include <ostream>
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4510)
+#pragma warning(disable:4610)
+#endif
+
+namespace boost {
+namespace random {
+namespace test {
+
+template<class Base = null_archetype<> >
+struct seed_seq_archetype : Base
+{
+ template<class Iter>
+ BOOST_CONCEPT_REQUIRES(
+ ((Mutable_RandomAccessIterator<Iter>))
+ ((UnsignedInteger<typename Mutable_RandomAccessIterator<Iter>::value_type>)),
+ (void))
+ generate(Iter, Iter) {}
+};
+
+template<class R = unsigned, class Base = null_archetype<> >
+struct uniform_random_number_generator_archetype : Base
+{
+ typedef R result_type;
+ static R min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
+ static R max BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
+ R operator()() { return 0; }
+};
+
+template<class SSeq>
+struct SeedSeq
+{
+public:
+ BOOST_CONCEPT_USAGE(SeedSeq)
+ {
+ q.generate(rb, re);
+ }
+private:
+ SSeq q;
+ mutable_random_access_iterator_archetype<boost::uint32_t> rb, re;
+};
+
+template<class T>
+struct Streamable
+{
+public:
+ BOOST_CONCEPT_USAGE(Streamable)
+ {
+ os << x;
+ is >> v;
+ wos << x;
+ wis >> v;
+ }
+private:
+ const T x;
+ T v;
+
+ std::istream is;
+ std::ostream os;
+ std::wistream wis;
+ std::wostream wos;
+};
+
+// Type deduction will fail unless the arguments have the same type.
+template <typename T>
+void same_type(T const&, T const&) {}
+
+template <class E>
+struct RandomNumberEngine :
+ DefaultConstructible<E>,
+ CopyConstructible<E>,
+ Assignable<E>,
+ EqualityComparable<E>,
+ Streamable<E>
+{
+public:
+ typedef typename E::result_type result_type;
+
+ // relaxed from the standard
+ BOOST_MPL_ASSERT((boost::is_arithmetic<result_type>));
+
+ // backwards compatibility check
+ BOOST_STATIC_ASSERT(!E::has_fixed_range);
+
+ // a generator can be used to seed another generator (extension)
+ BOOST_CONCEPT_ASSERT((SeedSeq<E>));
+
+ BOOST_CONCEPT_USAGE(RandomNumberEngine)
+ {
+ same_type(e(), result_type());
+ same_type((E::min)(), result_type());
+ same_type((E::max)(), result_type());
+
+ (void)E();
+ (void)E(s);
+ (void)E(q);
+
+ e.seed();
+ e.seed(s);
+ e.seed(q);
+
+ e.discard(z);
+
+ // extension
+ (void)E(sb, se);
+ e.seed(sb, se);
+ }
+
+private:
+ E e;
+ E v;
+ const E x;
+ seed_seq_archetype<> q;
+ typename detail::seed_type<result_type>::type s;
+ uintmax_t z;
+
+ input_iterator_archetype<boost::uint32_t> sb, se;
+};
+
+template<class D>
+struct RandomNumberDistribution :
+ DefaultConstructible<D>,
+ CopyConstructible<D>,
+ Assignable<D>,
+ EqualityComparable<D>,
+ Streamable<D>
+{
+public:
+ typedef typename D::result_type result_type;
+ typedef typename D::param_type param_type;
+ // backwards compatibility
+ typedef typename D::input_type input_type;
+
+ typedef param_type P;
+
+ BOOST_CONCEPT_ASSERT((DefaultConstructible<P>));
+ BOOST_CONCEPT_ASSERT((CopyConstructible<P>));
+ BOOST_CONCEPT_ASSERT((Assignable<P>));
+ BOOST_CONCEPT_ASSERT((EqualityComparable<P>));
+ BOOST_CONCEPT_ASSERT((Streamable<P>));
+
+ BOOST_MPL_ASSERT((boost::is_same<typename P::distribution_type, D>));
+
+ BOOST_CONCEPT_USAGE(RandomNumberDistribution)
+ {
+ (void)D(p);
+ d.reset();
+ same_type(x.param(), p);
+ d.param(p);
+ same_type(d(g), result_type());
+ same_type(d(g, p), result_type());
+ same_type((x.min)(), result_type());
+ same_type((x.max)(), result_type());
+ }
+
+private:
+ D d;
+ const D x;
+ const P p;
+ uniform_random_number_generator_archetype<> g;
+};
+
+}
+}
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+#endif
diff --git a/src/boost/libs/random/test/faure_validate.cpp b/src/boost/libs/random/test/faure_validate.cpp
new file mode 100644
index 000000000..0e87539a8
--- /dev/null
+++ b/src/boost/libs/random/test/faure_validate.cpp
@@ -0,0 +1,375 @@
+// Copyright Justinas Vygintas Daugmaudis, 2010.
+// Use, modification and distribution is subject to the
+// Boost Software License, Version 1.0. (See accompanying
+// file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
+
+#include <boost/random/faure.hpp>
+
+#include <boost/utility.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include "test_qrng_functions.hpp"
+
+//
+// DESCRIPTION:
+// ~~~~~~~~~~~~
+//
+// This file tests the faure quasi-random number generator.
+// These tests compare our results with values produced by the original
+// version of ACM TOMS Algorithm 647, which is available in the
+// TOMS subdirectory in http://www.netlib.org
+//
+// For independently generated datasets look at http://people.sc.fsu.edu/~jburkardt/datasets/faure/
+
+
+// Spatial dimension: 2
+// N: 100
+// Base: 2
+// Vectors skipped: 15
+static const double faure_02_100[100][2] =
+{
+ { 0.9375000000, 0.0625000000 },
+ { 0.0312500000, 0.5312500000 },
+ { 0.5312500000, 0.0312500000 },
+ { 0.2812500000, 0.2812500000 },
+ { 0.7812500000, 0.7812500000 },
+ { 0.1562500000, 0.1562500000 },
+ { 0.6562500000, 0.6562500000 },
+ { 0.4062500000, 0.9062500000 },
+ { 0.9062500000, 0.4062500000 },
+ { 0.0937500000, 0.4687500000 },
+ { 0.5937500000, 0.9687500000 },
+ { 0.3437500000, 0.7187500000 },
+ { 0.8437500000, 0.2187500000 },
+ { 0.2187500000, 0.8437500000 },
+ { 0.7187500000, 0.3437500000 },
+ { 0.4687500000, 0.0937500000 },
+ { 0.9687500000, 0.5937500000 },
+ { 0.0156250000, 0.7968750000 },
+ { 0.5156250000, 0.2968750000 },
+ { 0.2656250000, 0.0468750000 },
+ { 0.7656250000, 0.5468750000 },
+ { 0.1406250000, 0.4218750000 },
+ { 0.6406250000, 0.9218750000 },
+ { 0.3906250000, 0.6718750000 },
+ { 0.8906250000, 0.1718750000 },
+ { 0.0781250000, 0.2343750000 },
+ { 0.5781250000, 0.7343750000 },
+ { 0.3281250000, 0.9843750000 },
+ { 0.8281250000, 0.4843750000 },
+ { 0.2031250000, 0.6093750000 },
+ { 0.7031250000, 0.1093750000 },
+ { 0.4531250000, 0.3593750000 },
+ { 0.9531250000, 0.8593750000 },
+ { 0.0468750000, 0.2656250000 },
+ { 0.5468750000, 0.7656250000 },
+ { 0.2968750000, 0.5156250000 },
+ { 0.7968750000, 0.0156250000 },
+ { 0.1718750000, 0.8906250000 },
+ { 0.6718750000, 0.3906250000 },
+ { 0.4218750000, 0.1406250000 },
+ { 0.9218750000, 0.6406250000 },
+ { 0.1093750000, 0.7031250000 },
+ { 0.6093750000, 0.2031250000 },
+ { 0.3593750000, 0.4531250000 },
+ { 0.8593750000, 0.9531250000 },
+ { 0.2343750000, 0.0781250000 },
+ { 0.7343750000, 0.5781250000 },
+ { 0.4843750000, 0.8281250000 },
+ { 0.9843750000, 0.3281250000 },
+ { 0.0078125000, 0.6640625000 },
+ { 0.5078125000, 0.1640625000 },
+ { 0.2578125000, 0.4140625000 },
+ { 0.7578125000, 0.9140625000 },
+ { 0.1328125000, 0.0390625000 },
+ { 0.6328125000, 0.5390625000 },
+ { 0.3828125000, 0.7890625000 },
+ { 0.8828125000, 0.2890625000 },
+ { 0.0703125000, 0.3515625000 },
+ { 0.5703125000, 0.8515625000 },
+ { 0.3203125000, 0.6015625000 },
+ { 0.8203125000, 0.1015625000 },
+ { 0.1953125000, 0.9765625000 },
+ { 0.6953125000, 0.4765625000 },
+ { 0.4453125000, 0.2265625000 },
+ { 0.9453125000, 0.7265625000 },
+ { 0.0390625000, 0.1328125000 },
+ { 0.5390625000, 0.6328125000 },
+ { 0.2890625000, 0.8828125000 },
+ { 0.7890625000, 0.3828125000 },
+ { 0.1640625000, 0.5078125000 },
+ { 0.6640625000, 0.0078125000 },
+ { 0.4140625000, 0.2578125000 },
+ { 0.9140625000, 0.7578125000 },
+ { 0.1015625000, 0.8203125000 },
+ { 0.6015625000, 0.3203125000 },
+ { 0.3515625000, 0.0703125000 },
+ { 0.8515625000, 0.5703125000 },
+ { 0.2265625000, 0.4453125000 },
+ { 0.7265625000, 0.9453125000 },
+ { 0.4765625000, 0.6953125000 },
+ { 0.9765625000, 0.1953125000 },
+ { 0.0234375000, 0.3984375000 },
+ { 0.5234375000, 0.8984375000 },
+ { 0.2734375000, 0.6484375000 },
+ { 0.7734375000, 0.1484375000 },
+ { 0.1484375000, 0.7734375000 },
+ { 0.6484375000, 0.2734375000 },
+ { 0.3984375000, 0.0234375000 },
+ { 0.8984375000, 0.5234375000 },
+ { 0.0859375000, 0.5859375000 },
+ { 0.5859375000, 0.0859375000 },
+ { 0.3359375000, 0.3359375000 },
+ { 0.8359375000, 0.8359375000 },
+ { 0.2109375000, 0.2109375000 },
+ { 0.7109375000, 0.7109375000 },
+ { 0.4609375000, 0.9609375000 },
+ { 0.9609375000, 0.4609375000 },
+ { 0.0546875000, 0.9296875000 },
+ { 0.5546875000, 0.4296875000 },
+ { 0.3046875000, 0.1796875000 }
+};
+
+// Spatial dimension: 7
+// N: 100
+// Base: 7
+// Vectors skipped: 2400
+static const double faure_07_100[100][7] =
+{
+ { 0.9995835069, 0.4602249063, 0.9412744690, 0.3202832153, 0.9850062474, 0.8334027489, 0.1103706789 },
+ { 0.0000594990, 0.2437079788, 0.3765692866, 0.6493722854, 0.6685309692, 0.3582435890, 0.2228833224 },
+ { 0.1429166419, 0.3865651217, 0.5194264295, 0.7922294282, 0.8113881121, 0.5011007318, 0.3657404653 },
+ { 0.2857737847, 0.5294222645, 0.6622835723, 0.9350865711, 0.9542452550, 0.6439578747, 0.5085976081 },
+ { 0.4286309276, 0.6722794074, 0.8051407152, 0.0779437139, 0.0971023978, 0.7868150176, 0.6514547510 },
+ { 0.5714880704, 0.8151365502, 0.9479978580, 0.2208008568, 0.2399595407, 0.9296721604, 0.7943118939 },
+ { 0.7143452133, 0.9579936931, 0.0908550009, 0.3636579996, 0.3828166835, 0.0725293033, 0.9371690367 },
+ { 0.8572023562, 0.1008508360, 0.2337121437, 0.5065151425, 0.5256738264, 0.2153864461, 0.0800261796 },
+ { 0.0204676623, 0.4069732849, 0.6826917356, 0.0983518772, 0.2603677039, 0.0929374665, 0.1004343428 },
+ { 0.1633248051, 0.5498304278, 0.8255488784, 0.2412090201, 0.4032248468, 0.2357946094, 0.2432914857 },
+ { 0.3061819480, 0.6926875707, 0.9684060213, 0.3840661629, 0.5460819896, 0.3786517522, 0.3861486285 },
+ { 0.4490390909, 0.8355447135, 0.1112631642, 0.5269233058, 0.6889391325, 0.5215088951, 0.5290057714 },
+ { 0.5918962337, 0.9784018564, 0.2541203070, 0.6697804486, 0.8317962754, 0.6643660380, 0.6718629143 },
+ { 0.7347533766, 0.1212589992, 0.3969774499, 0.8126375915, 0.9746534182, 0.8072231808, 0.8147200571 },
+ { 0.8776105194, 0.2641161421, 0.5398345927, 0.9554947343, 0.1175105611, 0.9500803237, 0.9575772000 },
+ { 0.0408758255, 0.5702385911, 0.9888141846, 0.5473314690, 0.8522044386, 0.8276313441, 0.9779853632 },
+ { 0.1837329684, 0.7130957339, 0.1316713274, 0.6901886119, 0.9950615815, 0.9704884869, 0.1208425061 },
+ { 0.3265901113, 0.8559528768, 0.2745284703, 0.8330457547, 0.1379187243, 0.1133456298, 0.2636996490 },
+ { 0.4694472541, 0.9988100196, 0.4173856131, 0.9759028976, 0.2807758672, 0.2562027727, 0.4065567918 },
+ { 0.6123043970, 0.1416671625, 0.5602427560, 0.1187600405, 0.4236330101, 0.3990599155, 0.5494139347 },
+ { 0.7551615398, 0.2845243053, 0.7030998989, 0.2616171833, 0.5664901529, 0.5419170584, 0.6922710775 },
+ { 0.8980186827, 0.4273814482, 0.8459570417, 0.4044743262, 0.7093472958, 0.6847742012, 0.8351282204 },
+ { 0.0612839888, 0.5906467543, 0.1520794907, 0.9963110609, 0.3011840305, 0.5623252216, 0.8555363836 },
+ { 0.2041411317, 0.7335038972, 0.2949366335, 0.1391682037, 0.4440411733, 0.7051823645, 0.9983935265 },
+ { 0.3469982745, 0.8763610400, 0.4377937764, 0.2820253466, 0.5868983162, 0.8480395073, 0.1412506694 },
+ { 0.4898554174, 0.0192181829, 0.5806509193, 0.4248824894, 0.7297554590, 0.9908966502, 0.2841078122 },
+ { 0.6327125602, 0.1620753258, 0.7235080621, 0.5677396323, 0.8726126019, 0.1337537931, 0.4269649551 },
+ { 0.7755697031, 0.3049324686, 0.8663652050, 0.7105967752, 0.0154697447, 0.2766109359, 0.5698220979 },
+ { 0.9184268460, 0.4477896115, 0.0092223478, 0.8534539180, 0.1583268876, 0.4194680788, 0.7126792408 },
+ { 0.0816921521, 0.7539120605, 0.4582019397, 0.3024335098, 0.8930207652, 0.1541619563, 0.5902302612 },
+ { 0.2245492949, 0.8967692033, 0.6010590825, 0.4452906527, 0.0358779080, 0.2970190992, 0.7330874041 },
+ { 0.3674064378, 0.0396263462, 0.7439162254, 0.5881477956, 0.1787350509, 0.4398762420, 0.8759445469 },
+ { 0.5102635807, 0.1824834890, 0.8867733682, 0.7310049384, 0.3215921937, 0.5827333849, 0.0188016898 },
+ { 0.6531207235, 0.3253406319, 0.0296305111, 0.8738620813, 0.4644493366, 0.7255905278, 0.1616588326 },
+ { 0.7959778664, 0.4681977747, 0.1724876540, 0.0167192241, 0.6073064794, 0.8684476706, 0.3045159755 },
+ { 0.9388350092, 0.6110549176, 0.3153447968, 0.1595763670, 0.7501636223, 0.0113048135, 0.4473731183 },
+ { 0.1021003153, 0.9171773666, 0.7643243886, 0.7514131017, 0.4848574999, 0.8888558339, 0.4677812816 },
+ { 0.2449574582, 0.0600345094, 0.9071815315, 0.8942702445, 0.6277146427, 0.0317129767, 0.6106384245 },
+ { 0.3878146011, 0.2028916523, 0.0500386744, 0.0371273874, 0.7705717856, 0.1745701196, 0.7534955673 },
+ { 0.5306717439, 0.3457487951, 0.1928958172, 0.1799845303, 0.9134289284, 0.3174272625, 0.8963527102 },
+ { 0.6735288868, 0.4886059380, 0.3357529601, 0.3228416731, 0.0562860713, 0.4602844053, 0.0392098530 },
+ { 0.8163860296, 0.6314630809, 0.4786101029, 0.4656988160, 0.1991432141, 0.6031415482, 0.1820669959 },
+ { 0.9592431725, 0.7743202237, 0.6214672458, 0.6085559588, 0.3420003570, 0.7459986910, 0.3249241388 },
+ { 0.1225084786, 0.0804426727, 0.0704468376, 0.2003926935, 0.0766942345, 0.6235497114, 0.3453323020 },
+ { 0.2653656215, 0.2232998156, 0.2133039805, 0.3432498364, 0.2195513774, 0.7664068543, 0.4881894449 },
+ { 0.4082227643, 0.3661569584, 0.3561611233, 0.4861069792, 0.3624085203, 0.9092639971, 0.6310465877 },
+ { 0.5510799072, 0.5090141013, 0.4990182662, 0.6289641221, 0.5052656631, 0.0521211400, 0.7739037306 },
+ { 0.6939370500, 0.6518712441, 0.6418754091, 0.7718212649, 0.6481228060, 0.1949782829, 0.9167608734 },
+ { 0.8367941929, 0.7947283870, 0.7847325519, 0.9146784078, 0.7909799488, 0.3378354257, 0.0596180163 },
+ { 0.9796513358, 0.9375855298, 0.9275896948, 0.0575355507, 0.9338370917, 0.4806925686, 0.2024751592 },
+ { 0.0029749509, 0.4098887368, 0.8896888201, 0.9175938597, 0.9775688701, 0.9938121021, 0.3074314274 },
+ { 0.1458320938, 0.5527458797, 0.0325459630, 0.0604510026, 0.1204260130, 0.1366692450, 0.4502885702 },
+ { 0.2886892366, 0.6956030226, 0.1754031058, 0.2033081454, 0.2632831558, 0.2795263878, 0.5931457131 },
+ { 0.4315463795, 0.8384601654, 0.3182602487, 0.3461652883, 0.4061402987, 0.4223835307, 0.7360028560 },
+ { 0.5744035223, 0.9813173083, 0.4611173916, 0.4890224311, 0.5489974415, 0.5652406735, 0.8788599988 },
+ { 0.7172606652, 0.1241744511, 0.6039745344, 0.6318795740, 0.6918545844, 0.7080978164, 0.0217171417 },
+ { 0.8601178081, 0.2670315940, 0.7468316773, 0.7747367168, 0.8347117273, 0.8509549592, 0.1645742845 },
+ { 0.0233831142, 0.4302969001, 0.1958112691, 0.3665734515, 0.5694056048, 0.5856488368, 0.1849824478 },
+ { 0.1662402570, 0.5731540430, 0.3386684120, 0.5094305944, 0.7122627477, 0.7285059797, 0.3278395906 },
+ { 0.3090973999, 0.7160111858, 0.4815255548, 0.6522877373, 0.8551198905, 0.8713631225, 0.4706967335 },
+ { 0.4519545428, 0.8588683287, 0.6243826977, 0.7951448801, 0.9979770334, 0.0142202654, 0.6135538764 },
+ { 0.5948116856, 0.0017254715, 0.7672398405, 0.9380020230, 0.1408341762, 0.1570774082, 0.7564110192 },
+ { 0.7376688285, 0.1445826144, 0.9100969834, 0.0808591658, 0.2836913191, 0.2999345511, 0.8992681621 },
+ { 0.8805259713, 0.2874397572, 0.0529541263, 0.2237163087, 0.4265484620, 0.4427916939, 0.0421253049 },
+ { 0.0437912774, 0.5935622062, 0.5019337181, 0.8155530434, 0.0183851966, 0.3203427143, 0.0625334682 },
+ { 0.1866484203, 0.7364193491, 0.6447908610, 0.9584101862, 0.1612423395, 0.4631998572, 0.2053906111 },
+ { 0.3295055632, 0.8792764919, 0.7876480038, 0.1012673291, 0.3040994824, 0.6060570001, 0.3482477539 },
+ { 0.4723627060, 0.0221336348, 0.9305051467, 0.2441244719, 0.4469566252, 0.7489141429, 0.4911048968 },
+ { 0.6152198489, 0.1649907777, 0.0733622895, 0.3869816148, 0.5898137681, 0.8917712858, 0.6339620396 },
+ { 0.7580769917, 0.3078479205, 0.2162194324, 0.5298387577, 0.7326709109, 0.0346284286, 0.7768191825 },
+ { 0.9009341346, 0.4507050634, 0.3590765752, 0.6726959005, 0.8755280538, 0.1774855715, 0.9196763253 },
+ { 0.0641994407, 0.7568275123, 0.8080561671, 0.2645326352, 0.6102219313, 0.0550365919, 0.9400844886 },
+ { 0.2070565836, 0.8996846552, 0.9509133099, 0.4073897781, 0.7530790742, 0.1978937348, 0.0829416315 },
+ { 0.3499137264, 0.0425417981, 0.0937704528, 0.5502469209, 0.8959362171, 0.3407508776, 0.2257987743 },
+ { 0.4927708693, 0.1853989409, 0.2366275956, 0.6931040638, 0.0387933599, 0.4836080205, 0.3686559172 },
+ { 0.6356280121, 0.3282560838, 0.3794847385, 0.8359612066, 0.1816505028, 0.6264651633, 0.5115130600 },
+ { 0.7784851550, 0.4711132266, 0.5223418814, 0.9788183495, 0.3245076456, 0.7693223062, 0.6543702029 },
+ { 0.9213422979, 0.6139703695, 0.6651990242, 0.1216754924, 0.4673647885, 0.9121794490, 0.7972273457 },
+ { 0.0846076040, 0.9200928185, 0.1141786161, 0.7135122270, 0.2020586660, 0.7897304694, 0.8176355090 },
+ { 0.2274647468, 0.0629499613, 0.2570357589, 0.8563693699, 0.3449158089, 0.9325876123, 0.9604926519 },
+ { 0.3703218897, 0.2058071042, 0.3998929018, 0.9992265128, 0.4877729517, 0.0754447552, 0.1033497947 },
+ { 0.5131790325, 0.3486642470, 0.5427500446, 0.1420836556, 0.6306300946, 0.2183018980, 0.2462069376 },
+ { 0.6560361754, 0.4915213899, 0.6856071875, 0.2849407985, 0.7734872375, 0.3611590409, 0.3890640804 },
+ { 0.7988933183, 0.6343785328, 0.8284643303, 0.4277979413, 0.9163443803, 0.5040161837, 0.5319212233 },
+ { 0.9417504611, 0.7772356756, 0.9713214732, 0.5706550842, 0.0592015232, 0.6468733266, 0.6747783662 },
+ { 0.1050157672, 0.0833581246, 0.4203010650, 0.0196346760, 0.7938954007, 0.5244243470, 0.6951865294 },
+ { 0.2478729101, 0.2262152674, 0.5631582079, 0.1624918189, 0.9367525436, 0.6672814899, 0.8380436723 },
+ { 0.3907300530, 0.3690724103, 0.7060153507, 0.3053489617, 0.0796096864, 0.8101386327, 0.9809008151 },
+ { 0.5335871958, 0.5119295532, 0.8488724936, 0.4482061046, 0.2224668293, 0.9529957756, 0.1237579580 },
+ { 0.6764443387, 0.6547866960, 0.9917296365, 0.5910632475, 0.3653239722, 0.0958529184, 0.2666151009 },
+ { 0.8193014815, 0.7976438389, 0.1345867793, 0.7339203903, 0.5081811150, 0.2387100613, 0.4094722437 },
+ { 0.9621586244, 0.9405009817, 0.2774439222, 0.8767775332, 0.6510382579, 0.3815672041, 0.5523293866 },
+ { 0.1254239305, 0.2466234307, 0.5835663712, 0.4686142679, 0.3857321354, 0.2591182245, 0.4298804070 },
+ { 0.2682810734, 0.3894805736, 0.7264235140, 0.6114714107, 0.5285892783, 0.4019753674, 0.5727375498 },
+ { 0.4111382162, 0.5323377164, 0.8692806569, 0.7543285536, 0.6714464211, 0.5448325103, 0.7155946927 },
+ { 0.5539953591, 0.6751948593, 0.0121377997, 0.8971856964, 0.8143035640, 0.6876896531, 0.8584518355 },
+ { 0.6968525019, 0.8180520021, 0.1549949426, 0.0400428393, 0.9571607068, 0.8305467960, 0.0013089784 },
+ { 0.8397096448, 0.9609091450, 0.2978520854, 0.1828999822, 0.1000178497, 0.9734039388, 0.1441661213 },
+ { 0.9825667876, 0.1037662879, 0.4407092283, 0.3257571250, 0.2428749926, 0.1162610817, 0.2870232641 },
+ { 0.0058904028, 0.4536205153, 0.5456654965, 0.1654072708, 0.2661986077, 0.4865234724, 0.5552448385 }
+};
+
+
+// Spatial dimension: 16
+// N: 100
+// Base: 17
+// Vectors skipped: 83520
+static const double faure_16_100[100][16] =
+{
+ { 0.9999880270, 0.8056057758, 0.1198740437, 0.6486751835, 0.0390680188, 0.8792878438, 0.8198536895, 0.5009039643, 0.6317812287, 0.8007207768, 0.6547814322, 0.8998455478, 0.1276086254, 0.0370326026, 0.2198129812, 0.3230085847 },
+ { 0.0000007043, 0.0739342061, 0.9946008647, 0.7862221336, 0.0647149678, 0.7918135418, 0.2862640393, 0.2779667248, 0.9710738476, 0.9743784057, 0.2536854063, 0.2482376746, 0.8023258680, 0.1164384864, 0.8034393604, 0.9496301388 },
+ { 0.0588242337, 0.1327577355, 0.0534243941, 0.8450456630, 0.1235384972, 0.8506370712, 0.3450875687, 0.3367902542, 0.0298973770, 0.0332019351, 0.3125089358, 0.3070612041, 0.8611493974, 0.1752620158, 0.8622628899, 0.0084536682 },
+ { 0.1176477631, 0.1915812649, 0.1122479236, 0.9038691925, 0.1823620266, 0.9094606006, 0.4039110981, 0.3956137836, 0.0887209064, 0.0920254645, 0.3713324652, 0.3658847335, 0.9199729269, 0.2340855452, 0.9210864193, 0.0672771976 },
+ { 0.1764712925, 0.2504047943, 0.1710714530, 0.9626927219, 0.2411855560, 0.9682841300, 0.4627346275, 0.4544373131, 0.1475444358, 0.1508489939, 0.4301559946, 0.4247082629, 0.9787964563, 0.2929090746, 0.9799099487, 0.1261007270 },
+ { 0.2352948219, 0.3092283237, 0.2298949824, 0.0215162513, 0.3000090854, 0.0271076594, 0.5215581569, 0.5132608425, 0.2063679652, 0.2096725234, 0.4889795240, 0.4835317923, 0.0376199857, 0.3517326041, 0.0387334781, 0.1849242565 },
+ { 0.2941183514, 0.3680518531, 0.2887185118, 0.0803397807, 0.3588326148, 0.0859311888, 0.5803816863, 0.5720843719, 0.2651914946, 0.2684960528, 0.5478030534, 0.5423553217, 0.0964435151, 0.4105561335, 0.0975570075, 0.2437477859 },
+ { 0.3529418808, 0.4268753825, 0.3475420412, 0.1391633101, 0.4176561442, 0.1447547183, 0.6392052157, 0.6309079013, 0.3240150240, 0.3273195822, 0.6066265828, 0.6011788511, 0.1552670445, 0.4693796629, 0.1563805369, 0.3025713153 },
+ { 0.4117654102, 0.4856989119, 0.4063655706, 0.1979868395, 0.4764796737, 0.2035782477, 0.6980287451, 0.6897314307, 0.3828385535, 0.3861431116, 0.6654501122, 0.6600023805, 0.2140905739, 0.5282031923, 0.2152040663, 0.3613948447 },
+ { 0.4705889396, 0.5445224413, 0.4651891000, 0.2568103689, 0.5353032031, 0.2624017771, 0.7568522746, 0.7485549601, 0.4416620829, 0.4449666410, 0.7242736416, 0.7188259099, 0.2729141033, 0.5870267217, 0.2740275957, 0.4202183741 },
+ { 0.5294124690, 0.6033459708, 0.5240126294, 0.3156338983, 0.5941267325, 0.3212253065, 0.8156758040, 0.8073784895, 0.5004856123, 0.5037901704, 0.7830971711, 0.7776494393, 0.3317376327, 0.6458502511, 0.3328511251, 0.4790419035 },
+ { 0.5882359984, 0.6621695002, 0.5828361589, 0.3744574278, 0.6529502619, 0.3800488359, 0.8744993334, 0.8662020189, 0.5593091417, 0.5626136998, 0.8419207005, 0.8364729688, 0.3905611621, 0.7046737805, 0.3916746546, 0.5378654329 },
+ { 0.6470595278, 0.7209930296, 0.6416596883, 0.4332809572, 0.7117737913, 0.4388723653, 0.9333228628, 0.9250255483, 0.6181326711, 0.6214372292, 0.9007442299, 0.8952964982, 0.4493846916, 0.7634973099, 0.4504981840, 0.5966889623 },
+ { 0.7058830572, 0.7798165590, 0.7004832177, 0.4921044866, 0.7705973207, 0.4976958947, 0.9921463922, 0.9838490778, 0.6769562005, 0.6802607587, 0.9595677593, 0.9541200276, 0.5082082210, 0.8223208394, 0.5093217134, 0.6555124918 },
+ { 0.7647065866, 0.8386400884, 0.7593067471, 0.5509280160, 0.8294208501, 0.5565194241, 0.0509699216, 0.0426726072, 0.7357797299, 0.7390842881, 0.0183912887, 0.0129435570, 0.5670317504, 0.8811443688, 0.5681452428, 0.7143360212 },
+ { 0.8235301161, 0.8974636178, 0.8181302765, 0.6097515454, 0.8882443795, 0.6153429536, 0.1097934510, 0.1014961366, 0.7946032593, 0.7979078175, 0.0772148181, 0.0717670864, 0.6258552798, 0.9399678982, 0.6269687722, 0.7731595506 },
+ { 0.8823536455, 0.9562871472, 0.8769538059, 0.6685750748, 0.9470679090, 0.6741664830, 0.1686169804, 0.1603196660, 0.8534267888, 0.8567313469, 0.1360383475, 0.1305906158, 0.6846788092, 0.9987914276, 0.6857923016, 0.8319830800 },
+ { 0.9411771749, 0.0151106766, 0.9357773353, 0.7273986042, 0.0058914384, 0.7329900124, 0.2274405099, 0.2191431954, 0.9122503182, 0.9155548763, 0.1948618769, 0.1894141452, 0.7435023386, 0.0576149570, 0.7446158310, 0.8908066094 },
+ { 0.0034609119, 0.1362179431, 0.1157081312, 0.9661529295, 0.3034692930, 0.0893913965, 0.6426654233, 0.6931916383, 0.4451222905, 0.5072503780, 0.8453809081, 0.8987567058, 0.5116684286, 0.8257810470, 0.6304289798, 0.8354432876 },
+ { 0.0622844413, 0.1950414725, 0.1745316606, 0.0249764589, 0.3622928224, 0.1482149259, 0.7014889528, 0.7520151677, 0.5039458199, 0.5660739074, 0.9042044375, 0.9575802352, 0.5704919580, 0.8846045764, 0.6892525092, 0.8942668170 },
+ { 0.1211079707, 0.2538650019, 0.2333551900, 0.0837999883, 0.4211163519, 0.2070384553, 0.7603124822, 0.8108386971, 0.5627693493, 0.6248974369, 0.9630279669, 0.0164037646, 0.6293154874, 0.9434281058, 0.7480760386, 0.9530903464 },
+ { 0.1799315001, 0.3126885313, 0.2921787194, 0.1426235177, 0.4799398813, 0.2658619847, 0.8191360116, 0.8696622265, 0.6215928787, 0.6837209663, 0.0218514963, 0.0752272940, 0.6881390168, 0.0022516352, 0.8068995681, 0.0119138758 },
+ { 0.2387550296, 0.3715120607, 0.3510022488, 0.2014470471, 0.5387634107, 0.3246855141, 0.8779595410, 0.9284857560, 0.6804164081, 0.7425444957, 0.0806750257, 0.1340508234, 0.7469625462, 0.0610751646, 0.8657230975, 0.0707374052 },
+ { 0.2975785590, 0.4303355901, 0.4098257782, 0.2602705765, 0.5975869401, 0.3835090435, 0.9367830704, 0.9873092854, 0.7392399375, 0.8013680251, 0.1394985551, 0.1928743528, 0.8057860756, 0.1198986940, 0.9245466269, 0.1295609347 },
+ { 0.3564020884, 0.4891591195, 0.4686493076, 0.3190941060, 0.6564104695, 0.4423325729, 0.9956065998, 0.0461328148, 0.7980634670, 0.8601915545, 0.1983220845, 0.2516978823, 0.8646096051, 0.1787222234, 0.9833701563, 0.1883844641 },
+ { 0.4152256178, 0.5479826490, 0.5274728371, 0.3779176354, 0.7152339989, 0.5011561023, 0.0544301292, 0.1049563442, 0.8568869964, 0.9190150839, 0.2571456140, 0.3105214117, 0.9234331345, 0.2375457528, 0.0421936857, 0.2472079935 },
+ { 0.4740491472, 0.6068061784, 0.5862963665, 0.4367411648, 0.7740575283, 0.5599796318, 0.1132536586, 0.1637798736, 0.9157105258, 0.9778386133, 0.3159691434, 0.3693449411, 0.9822566639, 0.2963692823, 0.1010172151, 0.3060315229 },
+ { 0.5328726766, 0.6656297078, 0.6451198959, 0.4955646942, 0.8328810577, 0.6188031612, 0.1720771881, 0.2226034030, 0.9745340552, 0.0366621427, 0.3747926728, 0.4281684705, 0.0410801933, 0.3551928117, 0.1598407445, 0.3648550523 },
+ { 0.5916962060, 0.7244532372, 0.7039434253, 0.5543882236, 0.8917045872, 0.6776266906, 0.2309007175, 0.2814269324, 0.0333575846, 0.0954856721, 0.4336162022, 0.4869919999, 0.0999037227, 0.4140163411, 0.2186642739, 0.4236785817 },
+ { 0.6505197354, 0.7832767666, 0.7627669547, 0.6132117530, 0.9505281166, 0.7364502200, 0.2897242469, 0.3402504618, 0.0921811140, 0.1543092016, 0.4924397316, 0.5458155293, 0.1587272521, 0.4728398705, 0.2774878033, 0.4825021111 },
+ { 0.7093432648, 0.8421002960, 0.8215904841, 0.6720352824, 0.0093516460, 0.7952737494, 0.3485477763, 0.3990739913, 0.1510046434, 0.2131327310, 0.5512632610, 0.6046390587, 0.2175507815, 0.5316633999, 0.3363113328, 0.5413256405 },
+ { 0.7681667943, 0.9009238254, 0.8804140135, 0.7308588118, 0.0681751754, 0.8540972788, 0.4073713057, 0.4578975207, 0.2098281728, 0.2719562604, 0.6100867904, 0.6634625881, 0.2763743109, 0.5904869293, 0.3951348622, 0.6001491700 },
+ { 0.8269903237, 0.9597473548, 0.9392375429, 0.7896823412, 0.1269987048, 0.9129208082, 0.4661948351, 0.5167210501, 0.2686517022, 0.3307797898, 0.6689103198, 0.7222861175, 0.3351978403, 0.6493104587, 0.4539583916, 0.6589726994 },
+ { 0.8858138531, 0.0185708843, 0.9980610723, 0.8485058707, 0.1858222342, 0.9717443376, 0.5250183645, 0.5755445795, 0.3274752317, 0.3896033192, 0.7277338493, 0.7811096470, 0.3940213698, 0.7081339881, 0.5127819210, 0.7177962288 },
+ { 0.9446373825, 0.0773944137, 0.0568846018, 0.9073294001, 0.2446457636, 0.0305678670, 0.5838418939, 0.6343681089, 0.3862987611, 0.4484268486, 0.7865573787, 0.8399331764, 0.4528448992, 0.7669575176, 0.5716054504, 0.7766197582 },
+ { 0.0069211195, 0.1985016801, 0.1779918682, 0.1460837253, 0.5422236183, 0.3869692511, 0.9990668074, 0.1084165518, 0.9191707334, 0.0401223503, 0.4370764098, 0.5492757369, 0.2210109891, 0.5939471369, 0.4574185992, 0.7212564364 },
+ { 0.0657446489, 0.2573252095, 0.2368153976, 0.2049072547, 0.6010471477, 0.4457927805, 0.0578903368, 0.1672400812, 0.9779942628, 0.0989458798, 0.4958999392, 0.6080992663, 0.2798345185, 0.6527706663, 0.5162421286, 0.7800799658 },
+ { 0.1245681783, 0.3161487389, 0.2956389270, 0.2637307842, 0.6598706771, 0.5046163100, 0.1167138663, 0.2260636106, 0.0368177922, 0.1577694092, 0.5547234686, 0.6669227957, 0.3386580480, 0.7115941958, 0.5750656580, 0.8389034952 },
+ { 0.1833917078, 0.3749722683, 0.3544624564, 0.3225543136, 0.7186942065, 0.5634398394, 0.1755373957, 0.2848871400, 0.0956413216, 0.2165929386, 0.6135469980, 0.7257463252, 0.3974815774, 0.7704177252, 0.6338891874, 0.8977270246 },
+ { 0.2422152372, 0.4337957977, 0.4132859858, 0.3813778430, 0.7775177359, 0.6222633688, 0.2343609251, 0.3437106695, 0.1544648510, 0.2754164680, 0.6723705275, 0.7845698546, 0.4563051068, 0.8292412546, 0.6927127168, 0.9565505540 },
+ { 0.3010387666, 0.4926193272, 0.4721095153, 0.4402013724, 0.8363412654, 0.6810868982, 0.2931844545, 0.4025341989, 0.2132883804, 0.3342399974, 0.7311940569, 0.8433933840, 0.5151286362, 0.8880647840, 0.7515362463, 0.0153740834 },
+ { 0.3598622960, 0.5514428566, 0.5309330447, 0.4990249018, 0.8951647948, 0.7399104276, 0.3520079839, 0.4613577283, 0.2721119099, 0.3930635268, 0.7900175863, 0.9022169134, 0.5739521656, 0.9468883134, 0.8103597757, 0.0741976129 },
+ { 0.4186858254, 0.6102663860, 0.5897565741, 0.5578484312, 0.9539883242, 0.7987339570, 0.4108315133, 0.5201812577, 0.3309354393, 0.4518870562, 0.8488411157, 0.9610404428, 0.6327756950, 0.0057118428, 0.8691833051, 0.1330211423 },
+ { 0.4775093548, 0.6690899154, 0.6485801035, 0.6166719606, 0.0128118536, 0.8575574864, 0.4696550427, 0.5790047871, 0.3897589687, 0.5107105856, 0.9076646451, 0.0198639722, 0.6915992244, 0.0645353722, 0.9280068345, 0.1918446717 },
+ { 0.5363328842, 0.7279134448, 0.7074036329, 0.6754954900, 0.0716353830, 0.9163810158, 0.5284785721, 0.6378283165, 0.4485824981, 0.5695341151, 0.9664881745, 0.0786875016, 0.7504227538, 0.1233589016, 0.9868303639, 0.2506682011 },
+ { 0.5951564136, 0.7867369742, 0.7662271623, 0.7343190195, 0.1304589124, 0.9752045452, 0.5873021015, 0.6966518459, 0.5074060275, 0.6283576445, 0.0253117039, 0.1375110310, 0.8092462833, 0.1821824310, 0.0456538933, 0.3094917305 },
+ { 0.6539799431, 0.8455605036, 0.8250506917, 0.7931425489, 0.1892824418, 0.0340280747, 0.6461256310, 0.7554753753, 0.5662295569, 0.6871811739, 0.0841352333, 0.1963345605, 0.8680698127, 0.2410059605, 0.1044774227, 0.3683152599 },
+ { 0.7128034725, 0.9043840330, 0.8838742211, 0.8519660783, 0.2481059712, 0.0928516041, 0.7049491604, 0.8142989047, 0.6250530863, 0.7460047033, 0.1429587627, 0.2551580899, 0.9268933421, 0.2998294899, 0.1633009521, 0.4271387893 },
+ { 0.7716270019, 0.9632075625, 0.9426977505, 0.9107896077, 0.3069295006, 0.1516751335, 0.7637726898, 0.8731224342, 0.6838766157, 0.8048282327, 0.2017822922, 0.3139816193, 0.9857168715, 0.3586530193, 0.2221244815, 0.4859623187 },
+ { 0.8304505313, 0.0220310919, 0.0015212800, 0.9696131371, 0.3657530301, 0.2104986629, 0.8225962192, 0.9319459636, 0.7427001452, 0.8636517621, 0.2606058216, 0.3728051487, 0.0445404009, 0.4174765487, 0.2809480110, 0.5447858482 },
+ { 0.8892740607, 0.0808546213, 0.0603448094, 0.0284366665, 0.4245765595, 0.2693221923, 0.8814197486, 0.9907694930, 0.8015236746, 0.9224752915, 0.3194293510, 0.4316286781, 0.1033639303, 0.4763000781, 0.3397715404, 0.6036093776 },
+ { 0.9480975901, 0.1396781507, 0.1191683388, 0.0872601959, 0.4834000889, 0.3281457217, 0.9402432780, 0.0495930224, 0.8603472040, 0.9812988209, 0.3782528804, 0.4904522075, 0.1621874597, 0.5351236075, 0.3985950698, 0.6624329070 },
+ { 0.0103813271, 0.2607854171, 0.2990991346, 0.3260145212, 0.7809779436, 0.6845471058, 0.2966446621, 0.5236414653, 0.3932191763, 0.5729943227, 0.0287719115, 0.1997947681, 0.9303535497, 0.3621132269, 0.2844082186, 0.6070695852 },
+ { 0.0692048565, 0.3196089465, 0.3579226640, 0.3848380506, 0.8398014730, 0.7433706352, 0.3554681915, 0.5824649947, 0.4520427057, 0.6318178521, 0.0875954409, 0.2586182975, 0.9891770791, 0.4209367563, 0.3432317480, 0.6658931146 },
+ { 0.1280283860, 0.3784324759, 0.4167461935, 0.4436615800, 0.8986250024, 0.8021941646, 0.4142917209, 0.6412885241, 0.5108662351, 0.6906413815, 0.1464189704, 0.3174418269, 0.0480006085, 0.4797602857, 0.4020552774, 0.7247166440 },
+ { 0.1868519154, 0.4372560054, 0.4755697229, 0.5024851094, 0.9574485318, 0.8610176940, 0.4731152503, 0.7001120535, 0.5696897645, 0.7494649109, 0.2052424998, 0.3762653563, 0.1068241379, 0.5385838151, 0.4608788068, 0.7835401734 },
+ { 0.2456754448, 0.4960795348, 0.5343932523, 0.5613086388, 0.0162720612, 0.9198412234, 0.5319387798, 0.7589355829, 0.6285132939, 0.8082884403, 0.2640660292, 0.4350888857, 0.1656476673, 0.5974073445, 0.5197023362, 0.8423637028 },
+ { 0.3044989742, 0.5549030642, 0.5932167817, 0.6201321682, 0.0750955906, 0.9786647529, 0.5907623092, 0.8177591124, 0.6873368234, 0.8671119697, 0.3228895586, 0.4939124151, 0.2244711967, 0.6562308740, 0.5785258656, 0.9011872322 },
+ { 0.3633225036, 0.6137265936, 0.6520403111, 0.6789556977, 0.1339191200, 0.0374882823, 0.6495858386, 0.8765826418, 0.7461603528, 0.9259354991, 0.3817130880, 0.5527359445, 0.2832947262, 0.7150544034, 0.6373493950, 0.9600107616 },
+ { 0.4221460330, 0.6725501230, 0.7108638405, 0.7377792271, 0.1927426494, 0.0963118117, 0.7084093680, 0.9354061712, 0.8049838822, 0.9847590286, 0.4405366174, 0.6115594739, 0.3421182556, 0.7738779328, 0.6961729245, 0.0188342911 },
+ { 0.4809695624, 0.7313736524, 0.7696873699, 0.7966027565, 0.2515661788, 0.1551353411, 0.7672328974, 0.9942297006, 0.8638074116, 0.0435825580, 0.4993601468, 0.6703830034, 0.4009417850, 0.8327014622, 0.7549964539, 0.0776578205 },
+ { 0.5397930918, 0.7901971818, 0.8285108993, 0.8554262859, 0.3103897083, 0.2139588705, 0.8260564268, 0.0530532300, 0.9226309410, 0.1024060874, 0.5581836762, 0.7292065328, 0.4597653144, 0.8915249916, 0.8138199833, 0.1364813499 },
+ { 0.5986166213, 0.8490207112, 0.8873344287, 0.9142498153, 0.3692132377, 0.2727823999, 0.8848799562, 0.1118767594, 0.9814544704, 0.1612296168, 0.6170072057, 0.7880300622, 0.5185888438, 0.9503485210, 0.8726435127, 0.1953048793 },
+ { 0.6574401507, 0.9078442407, 0.9461579582, 0.9730733447, 0.4280367671, 0.3316059293, 0.9437034856, 0.1707002888, 0.0402779998, 0.2200531462, 0.6758307351, 0.8468535916, 0.5774123732, 0.0091720504, 0.9314670421, 0.2541284087 },
+ { 0.7162636801, 0.9666677701, 0.0049814876, 0.0318968741, 0.4868602965, 0.3904294587, 0.0025270150, 0.2295238182, 0.0991015292, 0.2788766756, 0.7346542645, 0.9056771210, 0.6362359026, 0.0679955798, 0.9902905715, 0.3129519381 },
+ { 0.7750872095, 0.0254912995, 0.0638050170, 0.0907204035, 0.5456838259, 0.4492529882, 0.0613505445, 0.2883473477, 0.1579250587, 0.3377002050, 0.7934777939, 0.9645006504, 0.6950594320, 0.1268191092, 0.0491141009, 0.3717754675 },
+ { 0.8339107389, 0.0843148289, 0.1226285464, 0.1495439329, 0.6045073553, 0.5080765176, 0.1201740739, 0.3471708771, 0.2167485881, 0.3965237344, 0.8523013233, 0.0233241798, 0.7538829615, 0.1856426387, 0.1079376303, 0.4305989969 },
+ { 0.8927342683, 0.1431383583, 0.1814520758, 0.2083674624, 0.6633308847, 0.5669000470, 0.1789976033, 0.4059944065, 0.2755721175, 0.4553472638, 0.9111248527, 0.0821477092, 0.8127064909, 0.2444661681, 0.1667611598, 0.4894225264 },
+ { 0.9515577977, 0.2019618877, 0.2402756052, 0.2671909918, 0.7221544141, 0.6257235764, 0.2378211327, 0.4648179359, 0.3343956469, 0.5141707933, 0.9699483821, 0.1409712387, 0.8715300203, 0.3032896975, 0.2255846892, 0.5482460558 },
+ { 0.0138415347, 0.3230691541, 0.4202064011, 0.5059453170, 0.0197322688, 0.9821249605, 0.6530460462, 0.9388663788, 0.8672676192, 0.1058662950, 0.6204674133, 0.8503137992, 0.6396961102, 0.1302793169, 0.1113978380, 0.4928827340 },
+ { 0.0726650642, 0.3818926836, 0.4790299305, 0.5647688464, 0.0785557982, 0.0409484899, 0.7118695756, 0.9976899082, 0.9260911486, 0.1646898244, 0.6792909427, 0.9091373286, 0.6985196397, 0.1891028463, 0.1702213674, 0.5517062634 },
+ { 0.1314885936, 0.4407162130, 0.5378534599, 0.6235923759, 0.1373793276, 0.0997720193, 0.7706931050, 0.0565134376, 0.9849146780, 0.2235133538, 0.7381144721, 0.9679608580, 0.7573431691, 0.2479263757, 0.2290448968, 0.6105297928 },
+ { 0.1903121230, 0.4995397424, 0.5966769893, 0.6824159053, 0.1962028570, 0.1585955487, 0.8295166344, 0.1153369670, 0.0437382074, 0.2823368832, 0.7969380015, 0.0267843874, 0.8161666985, 0.3067499051, 0.2878684262, 0.6693533222 },
+ { 0.2491356524, 0.5583632718, 0.6555005187, 0.7412394347, 0.2550263865, 0.2174190781, 0.8883401638, 0.1741604964, 0.1025617369, 0.3411604126, 0.8557615309, 0.0856079169, 0.8749902279, 0.3655734345, 0.3466919556, 0.7281768516 },
+ { 0.3079591818, 0.6171868012, 0.7143240481, 0.8000629641, 0.3138499159, 0.2762426075, 0.9471636932, 0.2329840259, 0.1613852663, 0.3999839420, 0.9145850603, 0.1444314463, 0.9338137573, 0.4243969639, 0.4055154850, 0.7870003810 },
+ { 0.3667827112, 0.6760103306, 0.7731475775, 0.8588864935, 0.3726734453, 0.3350661369, 0.0059872227, 0.2918075553, 0.2202087957, 0.4588074715, 0.9734085897, 0.2032549757, 0.9926372867, 0.4832204933, 0.4643390144, 0.8458239104 },
+ { 0.4256062406, 0.7348338600, 0.8319711069, 0.9177100229, 0.4314969747, 0.3938896664, 0.0648107521, 0.3506310847, 0.2790323251, 0.5176310009, 0.0322321192, 0.2620785051, 0.0514608161, 0.5420440227, 0.5231625438, 0.9046474398 },
+ { 0.4844297700, 0.7936573894, 0.8907946364, 0.9765335523, 0.4903205041, 0.4527131958, 0.1236342815, 0.4094546141, 0.3378558545, 0.5764545303, 0.0910556486, 0.3209020345, 0.1102843455, 0.6008675522, 0.5819860732, 0.9634709693 },
+ { 0.5432532995, 0.8524809189, 0.9496181658, 0.0353570817, 0.5491440335, 0.5115367252, 0.1824578109, 0.4682781435, 0.3966793839, 0.6352780597, 0.1498791780, 0.3797255639, 0.1691078749, 0.6596910816, 0.6408096027, 0.0222944987 },
+ { 0.6020768289, 0.9113044483, 0.0084416952, 0.0941806111, 0.6079675629, 0.5703602546, 0.2412813403, 0.5271016729, 0.4555029133, 0.6941015891, 0.2087027074, 0.4385490933, 0.2279314044, 0.7185146110, 0.6996331321, 0.0811180281 },
+ { 0.6609003583, 0.9701279777, 0.0672652246, 0.1530041406, 0.6667910923, 0.6291837840, 0.3001048697, 0.5859252023, 0.5143264427, 0.7529251185, 0.2675262368, 0.4973726227, 0.2867549338, 0.7773381404, 0.7584566615, 0.1399415575 },
+ { 0.7197238877, 0.0289515071, 0.1260887540, 0.2118276700, 0.7256146218, 0.6880073134, 0.3589283991, 0.6447487317, 0.5731499721, 0.8117486479, 0.3263497662, 0.5561961521, 0.3455784632, 0.8361616698, 0.8172801909, 0.1987650869 },
+ { 0.7785474171, 0.0877750365, 0.1849122834, 0.2706511994, 0.7844381512, 0.7468308428, 0.4177519285, 0.7035722612, 0.6319735016, 0.8705721773, 0.3851732956, 0.6150196816, 0.4044019926, 0.8949851992, 0.8761037203, 0.2575886163 },
+ { 0.8373709465, 0.1465985659, 0.2437358128, 0.3294747288, 0.8432616806, 0.8056543722, 0.4765754580, 0.7623957906, 0.6907970310, 0.9293957068, 0.4439968250, 0.6738432110, 0.4632255220, 0.9538087286, 0.9349272497, 0.3164121457 },
+ { 0.8961944759, 0.2054220953, 0.3025593422, 0.3882982582, 0.9020852100, 0.8644779016, 0.5353989874, 0.8212193200, 0.7496205604, 0.9882192362, 0.5028203544, 0.7326667404, 0.5220490514, 0.0126322580, 0.9937507791, 0.3752356751 },
+ { 0.9550180053, 0.2642456247, 0.3613828717, 0.4471217876, 0.9609087394, 0.9233014311, 0.5942225168, 0.8800428494, 0.8084440898, 0.0470427656, 0.5616438839, 0.7914902698, 0.5808725808, 0.0714557874, 0.0525743085, 0.4340592046 },
+ { 0.0173017424, 0.3853528912, 0.5413136675, 0.6858761129, 0.2584865941, 0.2797028151, 0.0094474303, 0.2952677629, 0.3413160621, 0.6387382673, 0.2121629150, 0.5008328303, 0.3490386708, 0.8984454068, 0.9383874573, 0.3786958828 },
+ { 0.0761252718, 0.4441764206, 0.6001371969, 0.7446996423, 0.3173101235, 0.3385263446, 0.0682709597, 0.3540912923, 0.4001395915, 0.6975617967, 0.2709864444, 0.5596563598, 0.4078622002, 0.9572689362, 0.9972109867, 0.4375194122 },
+ { 0.1349488012, 0.5029999500, 0.6589607263, 0.8035231717, 0.3761336529, 0.3973498740, 0.1270944891, 0.4129148217, 0.4589631209, 0.7563853261, 0.3298099738, 0.6184798892, 0.4666857296, 0.0160924656, 0.0560345162, 0.4963429416 },
+ { 0.1937723306, 0.5618234794, 0.7177842557, 0.8623467011, 0.4349571823, 0.4561734034, 0.1859180185, 0.4717383511, 0.5177866503, 0.8152088555, 0.3886335032, 0.6773034186, 0.5255092590, 0.0749159951, 0.1148580456, 0.5551664710 },
+ { 0.2525958600, 0.6206470088, 0.7766077852, 0.9211702305, 0.4937807117, 0.5149969328, 0.2447415479, 0.5305618805, 0.5766101798, 0.8740323850, 0.4474570326, 0.7361269480, 0.5843327884, 0.1337395245, 0.1736815750, 0.6139900004 },
+ { 0.3114193894, 0.6794705382, 0.8354313146, 0.9799937599, 0.5526042411, 0.5738204622, 0.3035650773, 0.5893854099, 0.6354337092, 0.9328559144, 0.5062805621, 0.7949504774, 0.6431563179, 0.1925630539, 0.2325051044, 0.6728135298 },
+ { 0.3702429188, 0.7382940676, 0.8942548440, 0.0388172893, 0.6114277705, 0.6326439916, 0.3623886067, 0.6482089394, 0.6942572386, 0.9916794438, 0.5651040915, 0.8537740068, 0.7019798473, 0.2513865833, 0.2913286338, 0.7316370592 },
+ { 0.4290664482, 0.7971175971, 0.9530783734, 0.0976408188, 0.6702513000, 0.6914675210, 0.4212121362, 0.7070324688, 0.7530807680, 0.0505029732, 0.6239276209, 0.9125975362, 0.7608033767, 0.3102101127, 0.3501521632, 0.7904605886 },
+ { 0.4878899777, 0.8559411265, 0.0119019028, 0.1564643482, 0.7290748294, 0.7502910504, 0.4800356656, 0.7658559982, 0.8119042974, 0.1093265026, 0.6827511503, 0.9714210656, 0.8196269061, 0.3690336421, 0.4089756926, 0.8492841180 },
+ { 0.5467135071, 0.9147646559, 0.0707254322, 0.2152878776, 0.7878983588, 0.8091145798, 0.5388591950, 0.8246795276, 0.8707278268, 0.1681500320, 0.7415746797, 0.0302445951, 0.8784504355, 0.4278571715, 0.4677992220, 0.9081076475 },
+ { 0.6055370365, 0.9735881853, 0.1295489616, 0.2741114070, 0.8467218882, 0.8679381093, 0.5976827244, 0.8835030570, 0.9295513562, 0.2269735614, 0.8003982091, 0.0890681245, 0.9372739649, 0.4866807009, 0.5266227514, 0.9669311769 },
+ { 0.6643605659, 0.0324117147, 0.1883724910, 0.3329349364, 0.9055454176, 0.9267616387, 0.6565062538, 0.9423265864, 0.9883748856, 0.2857970908, 0.8592217385, 0.1478916539, 0.9960974943, 0.5455042304, 0.5854462809, 0.0257547063 },
+ { 0.7231840953, 0.0912352441, 0.2471960204, 0.3917584658, 0.9643689470, 0.9855851681, 0.7153297832, 0.0011501158, 0.0471984151, 0.3446206202, 0.9180452679, 0.2067151833, 0.0549210237, 0.6043277598, 0.6442698103, 0.0845782357 },
+ { 0.7820076247, 0.1500587735, 0.3060195499, 0.4505819952, 0.0231924764, 0.0444086975, 0.7741533126, 0.0599736452, 0.1060219445, 0.4034441497, 0.9768687974, 0.2655387127, 0.1137445531, 0.6631512892, 0.7030933397, 0.1434017651 }
+};
+
+
+QRNG_VALIDATION_TEST_FUNCTIONS(faure)
+
+
+BOOST_AUTO_TEST_CASE( validate_faure )
+{
+ test_faure_values(faure_02_100, 15);
+ test_faure_values(faure_07_100, 2400);
+ test_faure_values(faure_16_100, 83520);
+}
+
+BOOST_AUTO_TEST_CASE( validate_faure_seed )
+{
+ test_faure_seed(faure_02_100, 15);
+ test_faure_seed(faure_07_100, 2400);
+ test_faure_seed(faure_16_100, 83520);
+}
+
+BOOST_AUTO_TEST_CASE( validate_faure_discard )
+{
+ test_faure_discard(faure_02_100, 15);
+ test_faure_discard(faure_07_100, 2400);
+ test_faure_discard(faure_16_100, 83520);
+}
diff --git a/src/boost/libs/random/test/histogram.cpp b/src/boost/libs/random/test/histogram.cpp
new file mode 100644
index 000000000..522a9df30
--- /dev/null
+++ b/src/boost/libs/random/test/histogram.cpp
@@ -0,0 +1,165 @@
+/* boost histogram.cpp graphical verification of distribution functions
+ *
+ * Copyright Jens Maurer 2000
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ * This test program allows to visibly examine the results of the
+ * distribution functions.
+ */
+
+#include <iostream>
+#include <iomanip>
+#include <vector>
+#include <algorithm>
+#include <cmath>
+#include <string>
+#include <boost/random.hpp>
+
+
+void plot_histogram(const std::vector<int>& slots, int samples,
+ double from, double to)
+{
+ int m = *std::max_element(slots.begin(), slots.end());
+ const int nRows = 20;
+ std::cout.setf(std::ios::fixed|std::ios::left);
+ std::cout.precision(5);
+ for(int r = 0; r < nRows; r++) {
+ double y = ((nRows - r) * double(m))/(nRows * samples);
+ std::cout << std::setw(10) << y << " ";
+ for(unsigned int col = 0; col < slots.size(); col++) {
+ char out = ' ';
+ if(slots[col]/double(samples) >= y)
+ out = 'x';
+ std::cout << out;
+ }
+ std::cout << std::endl;
+ }
+ std::cout << std::setw(12) << " "
+ << std::setw(10) << from;
+ std::cout.setf(std::ios::right, std::ios::adjustfield);
+ std::cout << std::setw(slots.size()-10) << to << std::endl;
+}
+
+// I am not sure whether these two should be in the library as well
+
+// maintain sum of NumberGenerator results
+template<class NumberGenerator,
+ class Sum = typename NumberGenerator::result_type>
+class sum_result
+{
+public:
+ typedef NumberGenerator base_type;
+ typedef typename base_type::result_type result_type;
+ explicit sum_result(const base_type & g) : gen(g), _sum(0) { }
+ result_type operator()() { result_type r = gen(); _sum += r; return r; }
+ base_type & base() { return gen; }
+ Sum sum() const { return _sum; }
+ void reset() { _sum = 0; }
+private:
+ base_type gen;
+ Sum _sum;
+};
+
+
+// maintain square sum of NumberGenerator results
+template<class NumberGenerator,
+ class Sum = typename NumberGenerator::result_type>
+class squaresum_result
+{
+public:
+ typedef NumberGenerator base_type;
+ typedef typename base_type::result_type result_type;
+ explicit squaresum_result(const base_type & g) : gen(g), _sum(0) { }
+ result_type operator()() { result_type r = gen(); _sum += r*r; return r; }
+ base_type & base() { return gen; }
+ Sum squaresum() const { return _sum; }
+ void reset() { _sum = 0; }
+private:
+ base_type gen;
+ Sum _sum;
+};
+
+
+template<class RNG>
+void histogram(RNG base, int samples, double from, double to,
+ const std::string & name)
+{
+ typedef squaresum_result<sum_result<RNG, double>, double > SRNG;
+ SRNG gen((sum_result<RNG, double>(base)));
+ const int nSlots = 60;
+ std::vector<int> slots(nSlots,0);
+ for(int i = 0; i < samples; i++) {
+ double val = gen();
+ if(val < from || val >= to) // early check avoids overflow
+ continue;
+ int slot = int((val-from)/(to-from) * nSlots);
+ if(slot < 0 || slot > (int)slots.size())
+ continue;
+ slots[slot]++;
+ }
+ std::cout << name << std::endl;
+ plot_histogram(slots, samples, from, to);
+ double mean = gen.base().sum() / samples;
+ std::cout << "mean: " << mean
+ << " sigma: " << std::sqrt(gen.squaresum()/samples-mean*mean)
+ << "\n" << std::endl;
+}
+
+template<class PRNG, class Dist>
+inline boost::variate_generator<PRNG&, Dist> make_gen(PRNG & rng, Dist d)
+{
+ return boost::variate_generator<PRNG&, Dist>(rng, d);
+}
+
+template<class PRNG>
+void histograms()
+{
+ PRNG rng;
+ using namespace boost;
+ histogram(make_gen(rng, uniform_smallint<>(0, 5)), 100000, -1, 6,
+ "uniform_smallint(0,5)");
+ histogram(make_gen(rng, uniform_int<>(0, 5)), 100000, -1, 6,
+ "uniform_int(0,5)");
+ histogram(make_gen(rng, uniform_real<>(0,1)), 100000, -0.5, 1.5,
+ "uniform_real(0,1)");
+ histogram(make_gen(rng, bernoulli_distribution<>(0.2)), 100000, -0.5, 1.5,
+ "bernoulli(0.2)");
+ histogram(make_gen(rng, binomial_distribution<>(4, 0.2)), 100000, -1, 5,
+ "binomial(4, 0.2)");
+ histogram(make_gen(rng, triangle_distribution<>(1, 2, 8)), 100000, 0, 10,
+ "triangle(1,2,8)");
+ histogram(make_gen(rng, geometric_distribution<>(5.0/6.0)), 100000, 0, 10,
+ "geometric(5/6)");
+ histogram(make_gen(rng, exponential_distribution<>(0.3)), 100000, 0, 10,
+ "exponential(0.3)");
+ histogram(make_gen(rng, cauchy_distribution<>()), 100000, -5, 5,
+ "cauchy");
+ histogram(make_gen(rng, lognormal_distribution<>(3, 2)), 100000, 0, 10,
+ "lognormal");
+ histogram(make_gen(rng, normal_distribution<>()), 100000, -3, 3,
+ "normal");
+ histogram(make_gen(rng, normal_distribution<>(0.5, 0.5)), 100000, -3, 3,
+ "normal(0.5, 0.5)");
+ histogram(make_gen(rng, poisson_distribution<>(1.5)), 100000, 0, 5,
+ "poisson(1.5)");
+ histogram(make_gen(rng, poisson_distribution<>(10)), 100000, 0, 20,
+ "poisson(10)");
+ histogram(make_gen(rng, gamma_distribution<>(0.5)), 100000, 0, 0.5,
+ "gamma(0.5)");
+ histogram(make_gen(rng, gamma_distribution<>(1)), 100000, 0, 3,
+ "gamma(1)");
+ histogram(make_gen(rng, gamma_distribution<>(2)), 100000, 0, 6,
+ "gamma(2)");
+}
+
+
+int main()
+{
+ histograms<boost::mt19937>();
+ // histograms<boost::lagged_fibonacci607>();
+}
+
diff --git a/src/boost/libs/random/test/integrate.hpp b/src/boost/libs/random/test/integrate.hpp
new file mode 100644
index 000000000..33766acd6
--- /dev/null
+++ b/src/boost/libs/random/test/integrate.hpp
@@ -0,0 +1,79 @@
+/* integrate.hpp header file
+ *
+ * Copyright Jens Maurer 2000
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ * Revision history
+ * 01 April 2001: Modified to use new <boost/limits.hpp> header. (JMaddock)
+ */
+
+#ifndef INTEGRATE_HPP
+#define INTEGRATE_HPP
+
+#include <boost/limits.hpp>
+
+template<class UnaryFunction>
+inline typename UnaryFunction::result_type
+trapezoid(UnaryFunction f, typename UnaryFunction::argument_type a,
+ typename UnaryFunction::argument_type b, int n)
+{
+ typename UnaryFunction::result_type tmp = 0;
+ for(int i = 1; i <= n-1; ++i)
+ tmp += f(a+(b-a)/n*i);
+ return (b-a)/2/n * (f(a) + f(b) + 2*tmp);
+}
+
+template<class UnaryFunction>
+inline typename UnaryFunction::result_type
+simpson(UnaryFunction f, typename UnaryFunction::argument_type a,
+ typename UnaryFunction::argument_type b, int n)
+{
+ typename UnaryFunction::result_type tmp1 = 0;
+ for(int i = 1; i <= n-1; ++i)
+ tmp1 += f(a+(b-a)/n*i);
+ typename UnaryFunction::result_type tmp2 = 0;
+ for(int i = 1; i <= n ; ++i)
+ tmp2 += f(a+(b-a)/2/n*(2*i-1));
+
+ return (b-a)/6/n * (f(a) + f(b) + 2*tmp1 + 4*tmp2);
+}
+
+// compute b so that f(b) = y; assume f is monotone increasing
+template<class UnaryFunction, class T>
+inline T
+invert_monotone_inc(UnaryFunction f, typename UnaryFunction::result_type y,
+ T lower = -1,
+ T upper = 1)
+{
+ while(upper-lower > 1e-6) {
+ double middle = (upper+lower)/2;
+ if(f(middle) > y)
+ upper = middle;
+ else
+ lower = middle;
+ }
+ return (upper+lower)/2;
+}
+
+// compute b so that I(f(x), a, b) == y
+template<class UnaryFunction>
+inline typename UnaryFunction::argument_type
+quantil(UnaryFunction f, typename UnaryFunction::argument_type a,
+ typename UnaryFunction::result_type y,
+ typename UnaryFunction::argument_type step)
+{
+ typedef typename UnaryFunction::result_type result_type;
+ if(y >= 1.0)
+ return std::numeric_limits<result_type>::infinity();
+ typename UnaryFunction::argument_type b = a;
+ for(result_type result = 0; result < y; b += step)
+ result += step*f(b);
+ return b;
+}
+
+
+#endif /* INTEGRATE_HPP */
diff --git a/src/boost/libs/random/test/multiprecision_float_test.cpp b/src/boost/libs/random/test/multiprecision_float_test.cpp
new file mode 100644
index 000000000..904c59d8f
--- /dev/null
+++ b/src/boost/libs/random/test/multiprecision_float_test.cpp
@@ -0,0 +1,198 @@
+
+/* multiprecision_float_test.cpp
+*
+* Copyright John Maddock 2015
+* Distributed under the Boost Software License, Version 1.0. (See
+* accompanying file LICENSE_1_0.txt or copy at
+* http://www.boost.org/LICENSE_1_0.txt)
+*
+* $Id$
+*
+* Tests all floating point related generators and distributions with multiprecision types.
+*/
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include <boost/core/ignore_unused.hpp>
+#include <boost/multiprecision/cpp_bin_float.hpp>
+#include <boost/multiprecision/cpp_int.hpp>
+#include <boost/multiprecision/debug_adaptor.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <boost/random.hpp>
+#include <sstream>
+
+
+typedef boost::multiprecision::number<boost::multiprecision::cpp_bin_float_100::backend_type, boost::multiprecision::et_on > big_float;
+typedef boost::random::subtract_with_carry_01_engine<big_float, 48, 10, 24 > ranlux_big_base_01;
+typedef boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::uint1024_t> large_int_generator;
+
+typedef boost::mpl::list <
+ boost::random::lagged_fibonacci_01_engine<big_float, 48, 44497, 21034 >,
+ boost::random::discard_block_engine< ranlux_big_base_01, 389, 24 >
+> engines;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(generator_test, engine_type, engines)
+{
+ typedef typename engine_type::result_type test_type;
+
+ boost::scoped_ptr<engine_type> gen(new engine_type());
+ unsigned seeds[] = { 1, 2, 3, 4 };
+ unsigned *p1 = seeds, *p2 = seeds + 4;
+ BOOST_CHECK_THROW(gen->seed(p1, p2), std::invalid_argument);
+ gen->seed();
+ gen->seed(2);
+ test_type a = gen->min();
+ test_type b = gen->max();
+ BOOST_CHECK(a < b);
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ test_type r = (*gen)();
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(a <= r);
+ BOOST_CHECK(b >= r);
+ }
+ gen->discard(20);
+
+ std::stringstream ss;
+ ss << std::setprecision(std::numeric_limits<test_type>::digits10 + 3) << *gen;
+ boost::scoped_ptr<engine_type> gen2(new engine_type());
+ ss >> *gen2;
+ BOOST_CHECK(*gen == *gen2);
+ (*gen2)();
+ BOOST_CHECK(*gen != *gen2);
+}
+
+typedef boost::mpl::list <
+ boost::random::bernoulli_distribution<big_float>,
+ boost::random::beta_distribution<big_float>,
+ boost::random::cauchy_distribution<big_float>,
+ boost::random::chi_squared_distribution<big_float>,
+ boost::random::exponential_distribution<big_float>,
+ boost::random::extreme_value_distribution<big_float>,
+ boost::random::fisher_f_distribution<big_float>,
+ boost::random::gamma_distribution<big_float>,
+ boost::random::laplace_distribution<big_float>,
+ boost::random::lognormal_distribution<big_float>,
+ boost::random::normal_distribution<big_float>,
+#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
+ boost::random::piecewise_constant_distribution<big_float>,
+ boost::random::piecewise_linear_distribution<big_float>,
+#endif
+ boost::random::student_t_distribution<big_float>,
+ boost::random::triangle_distribution<big_float>,
+ //boost::random::uniform_01<big_float>, // doesn't respect the concept! But gets used internally anyway.
+ boost::random::uniform_real_distribution<big_float>,
+ boost::random::uniform_on_sphere<big_float>,
+ boost::random::weibull_distribution<big_float>
+> distributions;
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(distributions_test, dist_type, distributions)
+{
+ typedef typename dist_type::result_type result_type;
+ dist_type d;
+ result_type a = (d.min)();
+ result_type b = (d.max)();
+ typename dist_type::param_type p = d.param();
+ boost::ignore_unused(p);
+ d.reset();
+
+ std::stringstream ss;
+ ss << std::setprecision(std::numeric_limits<result_type>::digits10 + 3) << d;
+ dist_type d2;
+ ss >> d2;
+ BOOST_CHECK(d == d2);
+
+ boost::random::mt19937 int_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(int_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= a);
+ BOOST_CHECK(r <= b);
+ }
+
+#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
+ large_int_generator big_int_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(big_int_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= a);
+ BOOST_CHECK(r <= b);
+ }
+
+ boost::random::discard_block_engine< ranlux_big_base_01, 389, 24 > big_float_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(big_float_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= a);
+ BOOST_CHECK(r <= b);
+ }
+#endif
+
+ boost::random::ranlux64_4_01 float_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(float_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= a);
+ BOOST_CHECK(r <= b);
+ }
+}
+
+
+
+BOOST_AUTO_TEST_CASE(canonical_test)
+{
+ typedef big_float result_type;
+
+ boost::random::mt19937 int_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = boost::random::generate_canonical<big_float, std::numeric_limits<big_float>::digits>(int_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= 0);
+ BOOST_CHECK(r <= 1);
+ }
+
+ large_int_generator big_int_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = boost::random::generate_canonical<big_float, std::numeric_limits<big_float>::digits>(big_int_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= 0);
+ BOOST_CHECK(r <= 1);
+ }
+
+
+ boost::random::discard_block_engine< ranlux_big_base_01, 389, 24 > big_float_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = boost::random::generate_canonical<big_float, std::numeric_limits<big_float>::digits>(big_float_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= 0);
+ BOOST_CHECK(r <= 1);
+ }
+
+ boost::random::ranlux64_4_01 float_gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = boost::random::generate_canonical<big_float, std::numeric_limits<big_float>::digits>(float_gen);
+ BOOST_CHECK((boost::math::isfinite)(r));
+ BOOST_CHECK(r >= 0);
+ BOOST_CHECK(r <= 1);
+ }
+
+}
+
diff --git a/src/boost/libs/random/test/multiprecision_int_test.cpp b/src/boost/libs/random/test/multiprecision_int_test.cpp
new file mode 100644
index 000000000..577e52aff
--- /dev/null
+++ b/src/boost/libs/random/test/multiprecision_int_test.cpp
@@ -0,0 +1,225 @@
+
+/* multiprecision_int_test.cpp
+*
+* Copyright John Maddock 2015
+* Distributed under the Boost Software License, Version 1.0. (See
+* accompanying file LICENSE_1_0.txt or copy at
+* http://www.boost.org/LICENSE_1_0.txt)
+*
+* $Id$
+*
+* Tests all integer related generators and distributions with multiprecision types:
+* discard_block, independent_bits_engine, random_number_generator,
+* xor_combine_engine, uniform_int_distribution, uniform_smallint.
+*
+* Not supported, but could be with more work (but probably not worth while):
+* shuffle_order_engine, binomial_distribution, discrete_distribution, negative_binomial_distribution,
+* poisson_distribution
+*/
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include <boost/core/ignore_unused.hpp>
+#include <boost/multiprecision/debug_adaptor.hpp>
+#include <boost/multiprecision/cpp_bin_float.hpp>
+#include <boost/multiprecision/cpp_int.hpp>
+#include <boost/random/independent_bits.hpp>
+#include <boost/random/discard_block.hpp>
+#include <boost/random/xor_combine.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/random_number_generator.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_smallint.hpp>
+#include <boost/random/discrete_distribution.hpp>
+#include <sstream>
+
+typedef boost::mpl::list <
+ boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::uint1024_t >,
+ boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::int1024_t >,
+ boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::checked_uint1024_t >,
+ boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::checked_int1024_t >,
+ boost::random::independent_bits_engine<boost::random::mt19937, 30000, boost::multiprecision::cpp_int >,
+ boost::random::discard_block_engine<boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::uint1024_t >, 20, 10>,
+ boost::random::discard_block_engine<boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::int1024_t >, 20, 10>,
+ boost::random::discard_block_engine<boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::checked_uint1024_t >, 20, 10>,
+ boost::random::discard_block_engine<boost::random::independent_bits_engine<boost::random::mt19937, 1024, boost::multiprecision::checked_int1024_t >, 20, 10>,
+ boost::random::discard_block_engine<boost::random::independent_bits_engine<boost::random::mt19937, 600, boost::multiprecision::cpp_int >, 20, 10>
+> engines;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(generator_test, engine_type, engines)
+{
+ typedef typename engine_type::result_type test_type;
+
+ engine_type gen;
+ gen.seed();
+ test_type a = gen.min();
+ test_type b = gen.max();
+ BOOST_CHECK(a < b);
+ a = gen();
+ //
+ // This extracts 32-bit values for use in seeding other sequences,
+ // not really applicable here, and not functional for signed types anyway.
+ //gen.generate(&b, &b + 1);
+ gen.discard(20);
+
+ typename engine_type::base_type base(gen.base());
+ boost::ignore_unused(base);
+
+ std::stringstream ss;
+ ss << gen;
+ engine_type gen2;
+ ss >> gen2;
+ BOOST_CHECK(gen == gen2);
+ gen2();
+ BOOST_CHECK(gen != gen2);
+ //
+ // construction and seeding:
+ //
+ engine_type gen3(0);
+ gen3.seed(2);
+}
+
+BOOST_AUTO_TEST_CASE(xor_combine_test)
+{
+ //
+ // As above but with a few things missing which don't work - for example we have no
+ // way to drill down and get the seed-type of the underlying generator.
+ //
+ typedef boost::random::xor_combine_engine<boost::random::independent_bits_engine<boost::random::mt19937, 512, boost::multiprecision::uint1024_t >, 512, boost::random::independent_bits_engine<boost::random::mt19937, 512, boost::multiprecision::uint1024_t >, 10> engine_type;
+ typedef engine_type::result_type test_type;
+
+ engine_type gen;
+ gen.seed();
+ test_type a = gen.min();
+ test_type b = gen.max();
+ BOOST_CHECK(a < b);
+ a = gen();
+#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
+ gen.generate(&b, &b + 1);
+#endif
+ gen.discard(20);
+
+ //typename engine_type::base_type base(gen.base());
+
+ std::stringstream ss;
+ ss << gen;
+ engine_type gen2;
+ ss >> gen2;
+ BOOST_CHECK(gen == gen2);
+ gen2();
+ BOOST_CHECK(gen != gen2);
+ //
+ // construction and seeding:
+ //
+ //engine_type gen3(0);
+ //gen3.seed(2);
+}
+
+typedef boost::mpl::list <
+ boost::random::random_number_generator<boost::random::mt19937, boost::multiprecision::cpp_int>,
+ boost::random::random_number_generator<boost::random::mt19937, boost::multiprecision::uint1024_t>,
+ boost::random::random_number_generator<boost::random::mt19937, boost::multiprecision::checked_uint1024_t>
+> generators;
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(random_number_generator, generator_type, generators)
+{
+ typedef typename generator_type::result_type result_type;
+ typedef typename generator_type::base_type base_type;
+
+ result_type lim = 1;
+ lim <<= 500;
+
+ base_type base;
+ generator_type gen(base);
+
+ for(unsigned i = 0; i < 100; ++i)
+ BOOST_CHECK(gen(lim) < lim);
+}
+
+typedef boost::mpl::list <
+ boost::random::uniform_int_distribution<boost::multiprecision::cpp_int>,
+ boost::random::uniform_int_distribution<boost::multiprecision::uint1024_t>,
+ boost::random::uniform_int_distribution<boost::multiprecision::checked_uint1024_t>,
+ boost::random::uniform_smallint<boost::multiprecision::cpp_int>,
+ boost::random::uniform_smallint<boost::multiprecision::uint1024_t>,
+ boost::random::uniform_smallint<boost::multiprecision::checked_uint1024_t>
+> uniform_distributions;
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(distributions, distribution_type, uniform_distributions)
+{
+ typedef typename distribution_type::result_type result_type;
+
+ result_type a = 20;
+ result_type b = 1;
+ b <<= 1000;
+
+ distribution_type d(a, b);
+ boost::random::mt19937 gen;
+
+ BOOST_CHECK_EQUAL(d.a(), a);
+ BOOST_CHECK_EQUAL(d.b(), b);
+ BOOST_CHECK_EQUAL((d.min)(), a);
+ BOOST_CHECK_EQUAL((d.max)(), b);
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(gen);
+ BOOST_CHECK(r <= b);
+ BOOST_CHECK(r >= a);
+ }
+
+ std::stringstream ss;
+ ss << d;
+ distribution_type d2;
+ ss >> d2;
+ BOOST_CHECK(d == d2);
+
+ boost::random::independent_bits_engine<boost::random::mt19937, std::numeric_limits<boost::multiprecision::uint1024_t>::digits, boost::multiprecision::uint1024_t > big_random;
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(big_random);
+ BOOST_CHECK(r <= b);
+ BOOST_CHECK(r >= a);
+ }
+}
+
+#ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS
+
+typedef boost::mpl::list <
+ boost::random::discrete_distribution < boost::multiprecision::cpp_int, double>,
+ boost::random::discrete_distribution <unsigned int, boost::multiprecision::cpp_bin_float_100>
+> other_distributions;
+
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(discrete_distributions, distribution_type, other_distributions)
+{
+ typedef typename distribution_type::result_type result_type;
+ typedef typename distribution_type::input_type input_type;
+
+ input_type a[] = { 20, 30, 40, 50 };
+
+ distribution_type d(a, a + 4);
+ boost::random::mt19937 gen;
+
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(gen);
+ }
+
+ std::stringstream ss;
+ ss << std::setprecision(std::numeric_limits<input_type>::digits10 + 3) << d;
+ distribution_type d2;
+ ss >> d2;
+ BOOST_CHECK(d == d2);
+
+ boost::random::independent_bits_engine<boost::random::mt19937, std::numeric_limits<boost::multiprecision::uint1024_t>::digits, boost::multiprecision::uint1024_t > big_random;
+ for(unsigned i = 0; i < 200; ++i)
+ {
+ result_type r = d(big_random);
+ }
+}
+
+#endif
diff --git a/src/boost/libs/random/test/niederreiter_base2_validate.cpp b/src/boost/libs/random/test/niederreiter_base2_validate.cpp
new file mode 100644
index 000000000..132536ec9
--- /dev/null
+++ b/src/boost/libs/random/test/niederreiter_base2_validate.cpp
@@ -0,0 +1,379 @@
+// Copyright Justinas Vygintas Daugmaudis, 2010-2018.
+// Use, modification and distribution is subject to the
+// Boost Software License, Version 1.0. (See accompanying
+// file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
+
+#include <boost/random/niederreiter_base2.hpp>
+
+#include <boost/utility.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include "test_qrng_functions.hpp"
+
+//
+// DESCRIPTION:
+// ~~~~~~~~~~~~
+//
+// This file tests the faure quasi-random number generator.
+// These tests compare our results with values produced by the original
+// version of ACM TOMS Algorithm 738, which is available in the
+// TOMS subdirectory in http://www.netlib.org
+//
+// For independently generated datasets look at http://people.sc.fsu.edu/~jburkardt/datasets/niederreiter2/
+
+
+// Spatial dimension: 2
+// N: 100
+// Vectors skipped: 4095
+static const double niederreiter_base2_02_100[100][2] =
+{
+ { 0.0003662109, 0.4705810548 },
+ { 0.5003662111, 0.9705810549 },
+ { 0.7503662111, 0.2205810547 },
+ { 0.2503662110, 0.7205810549 },
+ { 0.3753662110, 0.0955810547 },
+ { 0.8753662111, 0.5955810548 },
+ { 0.6253662111, 0.3455810548 },
+ { 0.1253662110, 0.8455810549 },
+ { 0.1878662110, 0.1580810547 },
+ { 0.6878662111, 0.6580810548 },
+ { 0.9378662112, 0.4080810548 },
+ { 0.4378662110, 0.9080810549 },
+ { 0.3128662110, 0.2830810548 },
+ { 0.8128662111, 0.7830810549 },
+ { 0.5628662111, 0.0330810547 },
+ { 0.0628662110, 0.5330810548 },
+ { 0.0941162110, 0.0018310547 },
+ { 0.5941162111, 0.5018310548 },
+ { 0.8441162111, 0.2518310547 },
+ { 0.3441162110, 0.7518310549 },
+ { 0.4691162110, 0.3768310548 },
+ { 0.9691162112, 0.8768310549 },
+ { 0.7191162111, 0.1268310547 },
+ { 0.2191162110, 0.6268310548 },
+ { 0.1566162110, 0.3143310548 },
+ { 0.6566162111, 0.8143310549 },
+ { 0.9066162111, 0.0643310547 },
+ { 0.4066162110, 0.5643310548 },
+ { 0.2816162110, 0.1893310547 },
+ { 0.7816162111, 0.6893310548 },
+ { 0.5316162111, 0.4393310548 },
+ { 0.0316162109, 0.9393310549 },
+ { 0.0472412109, 0.2362060547 },
+ { 0.5472412111, 0.7362060549 },
+ { 0.7972412111, 0.4862060548 },
+ { 0.2972412110, 0.9862060549 },
+ { 0.4222412110, 0.3612060548 },
+ { 0.9222412112, 0.8612060549 },
+ { 0.6722412111, 0.1112060547 },
+ { 0.1722412110, 0.6112060548 },
+ { 0.2347412110, 0.4237060548 },
+ { 0.7347412111, 0.9237060549 },
+ { 0.9847412112, 0.1737060547 },
+ { 0.4847412111, 0.6737060548 },
+ { 0.3597412110, 0.0487060547 },
+ { 0.8597412111, 0.5487060548 },
+ { 0.6097412111, 0.2987060548 },
+ { 0.1097412110, 0.7987060549 },
+ { 0.0784912110, 0.2674560547 },
+ { 0.5784912111, 0.7674560549 },
+ { 0.8284912111, 0.0174560547 },
+ { 0.3284912110, 0.5174560548 },
+ { 0.4534912110, 0.1424560547 },
+ { 0.9534912112, 0.6424560548 },
+ { 0.7034912111, 0.3924560548 },
+ { 0.2034912110, 0.8924560549 },
+ { 0.1409912110, 0.0799560547 },
+ { 0.6409912111, 0.5799560548 },
+ { 0.8909912111, 0.3299560548 },
+ { 0.3909912110, 0.8299560549 },
+ { 0.2659912110, 0.4549560548 },
+ { 0.7659912111, 0.9549560549 },
+ { 0.5159912111, 0.2049560547 },
+ { 0.0159912109, 0.7049560549 },
+ { 0.0238037109, 0.1190185547 },
+ { 0.5238037111, 0.6190185548 },
+ { 0.7738037111, 0.3690185548 },
+ { 0.2738037110, 0.8690185549 },
+ { 0.3988037110, 0.4940185548 },
+ { 0.8988037111, 0.9940185549 },
+ { 0.6488037111, 0.2440185547 },
+ { 0.1488037110, 0.7440185549 },
+ { 0.2113037110, 0.3065185548 },
+ { 0.7113037111, 0.8065185549 },
+ { 0.9613037112, 0.0565185547 },
+ { 0.4613037110, 0.5565185548 },
+ { 0.3363037110, 0.1815185547 },
+ { 0.8363037111, 0.6815185548 },
+ { 0.5863037111, 0.4315185548 },
+ { 0.0863037110, 0.9315185549 },
+ { 0.1175537110, 0.4002685548 },
+ { 0.6175537111, 0.9002685549 },
+ { 0.8675537111, 0.1502685547 },
+ { 0.3675537110, 0.6502685548 },
+ { 0.4925537111, 0.0252685547 },
+ { 0.9925537112, 0.5252685548 },
+ { 0.7425537111, 0.2752685548 },
+ { 0.2425537110, 0.7752685549 },
+ { 0.1800537110, 0.2127685547 },
+ { 0.6800537111, 0.7127685549 },
+ { 0.9300537112, 0.4627685548 },
+ { 0.4300537110, 0.9627685549 },
+ { 0.3050537110, 0.3377685548 },
+ { 0.8050537111, 0.8377685549 },
+ { 0.5550537111, 0.0877685547 },
+ { 0.0550537110, 0.5877685548 },
+ { 0.0394287109, 0.3533935548 },
+ { 0.5394287111, 0.8533935549 },
+ { 0.7894287111, 0.1033935547 },
+ { 0.2894287110, 0.6033935548 }
+};
+
+// Spatial dimension: 7
+// N: 100
+// Vectors skipped: 4095
+static const double niederreiter_base2_07_100[100][7] =
+{
+ { 0.0003662109, 0.4705810548, 0.6358642580, 0.9561767580, 0.6715087892, 0.9793701174, 0.6053466798 },
+ { 0.5003662111, 0.9705810549, 0.3858642579, 0.0811767578, 0.2965087891, 0.0418701172, 0.4178466798 },
+ { 0.7503662111, 0.2205810547, 0.9483642580, 0.8155517580, 0.5621337892, 0.9207763674, 0.5467529298 },
+ { 0.2503662110, 0.7205810549, 0.1983642579, 0.1905517579, 0.4371337892, 0.1082763672, 0.4842529298 },
+ { 0.3753662110, 0.0955810547, 0.2608642579, 0.7374267580, 0.7652587892, 0.8465576174, 0.6600341798 },
+ { 0.8753662111, 0.5955810548, 0.5108642579, 0.3624267579, 0.1402587891, 0.1590576172, 0.3475341798 },
+ { 0.6253662111, 0.3455810548, 0.0733642578, 0.5968017580, 0.9058837893, 0.7879638674, 0.7264404299 },
+ { 0.1253662110, 0.8455810549, 0.8233642580, 0.4718017579, 0.0308837891, 0.2254638672, 0.2889404298 },
+ { 0.1878662110, 0.1580810547, 0.1514892578, 0.2686767579, 0.3590087891, 0.7449951174, 0.9334716799 },
+ { 0.6878662111, 0.6580810548, 0.9014892580, 0.6436767580, 0.7340087892, 0.3074951173, 0.1209716797 },
+ { 0.9378662112, 0.4080810548, 0.4639892579, 0.3780517579, 0.4996337892, 0.6864013673, 0.9998779299 },
+ { 0.4378662110, 0.9080810549, 0.7139892580, 0.5030517579, 0.6246337892, 0.3739013673, 0.0623779297 },
+ { 0.3128662110, 0.2830810548, 0.7764892580, 0.0499267578, 0.2027587891, 0.6121826173, 0.8631591799 },
+ { 0.8128662111, 0.7830810549, 0.0264892578, 0.9249267580, 0.8277587893, 0.4246826173, 0.1756591797 },
+ { 0.5628662111, 0.0330810547, 0.5889892579, 0.1593017578, 0.0933837891, 0.5535888673, 0.8045654299 },
+ { 0.0628662110, 0.5330810548, 0.3389892579, 0.7843017580, 0.9683837893, 0.4910888673, 0.2420654297 },
+ { 0.0941162110, 0.0018310547, 0.9171142580, 0.5635986329, 0.4195556642, 0.3856201173, 0.3865966798 },
+ { 0.5941162111, 0.5018310548, 0.1671142579, 0.4385986329, 0.5445556642, 0.5731201173, 0.5740966798 },
+ { 0.8441162111, 0.2518310547, 0.7296142580, 0.7042236330, 0.3101806641, 0.4520263673, 0.4530029298 },
+ { 0.3441162110, 0.7518310549, 0.4796142579, 0.3292236329, 0.6851806642, 0.5145263673, 0.5155029298 },
+ { 0.4691162110, 0.3768310548, 0.0421142578, 0.8448486330, 0.0133056641, 0.2528076172, 0.3162841798 },
+ { 0.9691162112, 0.8768310549, 0.7921142580, 0.2198486329, 0.8883056643, 0.6903076173, 0.6287841798 },
+ { 0.7191162111, 0.1268310547, 0.3546142579, 0.9854736330, 0.1539306641, 0.3192138673, 0.2576904297 },
+ { 0.2191162110, 0.6268310548, 0.6046142580, 0.1104736328, 0.7789306642, 0.6317138673, 0.6951904298 },
+ { 0.1566162110, 0.3143310548, 0.4327392579, 0.1260986328, 0.6070556642, 0.1512451172, 0.0897216797 },
+ { 0.6566162111, 0.8143310549, 0.6827392580, 0.7510986330, 0.4820556642, 0.8387451174, 0.9022216799 },
+ { 0.9066162111, 0.0643310547, 0.2452392579, 0.0167236328, 0.7476806642, 0.2176513672, 0.0311279297 },
+ { 0.4066162110, 0.5643310548, 0.9952392580, 0.8917236330, 0.3726806641, 0.7801513674, 0.9686279299 },
+ { 0.2816162110, 0.1893310547, 0.5577392579, 0.4073486329, 0.9508056643, 0.0184326172, 0.1444091797 },
+ { 0.7816162111, 0.6893310548, 0.3077392579, 0.5323486329, 0.0758056641, 0.9559326174, 0.8319091799 },
+ { 0.5316162111, 0.4393310548, 0.8702392580, 0.2979736329, 0.8414306643, 0.0848388672, 0.2108154297 },
+ { 0.0316162109, 0.9393310549, 0.1202392578, 0.6729736330, 0.2164306641, 0.8973388674, 0.7733154299 },
+ { 0.0472412109, 0.2362060547, 0.4522705079, 0.1007080078, 0.0426025391, 0.7955322267, 0.4801025392 },
+ { 0.5472412111, 0.7362060549, 0.7022705080, 0.9757080080, 0.9176025393, 0.2330322266, 0.5426025392 },
+ { 0.7972412111, 0.4862060548, 0.1397705078, 0.2413330079, 0.1832275391, 0.8541259768, 0.4215087892 },
+ { 0.2972412110, 0.9862060549, 0.8897705080, 0.8663330080, 0.8082275393, 0.1666259766, 0.6090087892 },
+ { 0.4222412110, 0.3612060548, 0.5772705079, 0.3194580079, 0.3863525392, 0.9127197268, 0.2847900391 },
+ { 0.9222412112, 0.8612060549, 0.3272705079, 0.6944580080, 0.5113525392, 0.1002197266, 0.7222900392 },
+ { 0.6722412111, 0.1112060547, 0.7647705080, 0.4600830079, 0.2769775391, 0.9713134768, 0.3511962891 },
+ { 0.1722412110, 0.6112060548, 0.0147705078, 0.5850830079, 0.6519775392, 0.0338134766, 0.6636962892 },
+ { 0.2347412110, 0.4237060548, 0.9678955080, 0.6632080080, 0.9801025393, 0.5611572267, 0.0582275391 },
+ { 0.7347412111, 0.9237060549, 0.2178955079, 0.2882080079, 0.1051025391, 0.4986572267, 0.9957275393 },
+ { 0.9847412112, 0.1737060547, 0.6553955080, 0.5538330079, 0.8707275393, 0.6197509767, 0.1246337891 },
+ { 0.4847412111, 0.6737060548, 0.4053955079, 0.4288330079, 0.2457275391, 0.4322509767, 0.9371337893 },
+ { 0.3597412110, 0.0487060547, 0.0928955078, 0.8819580080, 0.5738525392, 0.6783447267, 0.2379150391 },
+ { 0.8597412111, 0.5487060548, 0.8428955080, 0.0069580078, 0.4488525392, 0.3658447266, 0.8004150392 },
+ { 0.6097412111, 0.2987060548, 0.2803955079, 0.7725830080, 0.7144775392, 0.7369384767, 0.1793212891 },
+ { 0.1097412110, 0.7987060549, 0.5303955079, 0.1475830078, 0.3394775391, 0.2994384766, 0.8668212893 },
+ { 0.0784912110, 0.2674560547, 0.2335205079, 0.4893798829, 0.7906494142, 0.3267822266, 0.5113525392 },
+ { 0.5784912111, 0.7674560549, 0.9835205080, 0.6143798830, 0.1656494141, 0.6392822267, 0.4488525392 },
+ { 0.8284912111, 0.0174560547, 0.4210205079, 0.3487548829, 0.9312744143, 0.2603759766, 0.5777587892 },
+ { 0.3284912110, 0.5174560548, 0.6710205080, 0.7237548830, 0.0562744141, 0.6978759767, 0.3902587892 },
+ { 0.4534912110, 0.1424560547, 0.8585205080, 0.2081298829, 0.6343994142, 0.4439697267, 0.6910400392 },
+ { 0.9534912112, 0.6424560548, 0.1085205078, 0.8331298830, 0.2593994141, 0.5064697267, 0.2535400391 },
+ { 0.7034912111, 0.3924560548, 0.5460205079, 0.0675048828, 0.5250244142, 0.3775634767, 0.6324462892 },
+ { 0.2034912110, 0.8924560549, 0.2960205079, 0.9425048830, 0.4000244142, 0.5650634767, 0.3199462891 },
+ { 0.1409912110, 0.0799560547, 0.7491455080, 0.8018798830, 0.2281494141, 0.0924072266, 0.9644775393 },
+ { 0.6409912111, 0.5799560548, 0.4991455079, 0.1768798829, 0.8531494143, 0.9049072268, 0.0269775391 },
+ { 0.8909912111, 0.3299560548, 0.9366455080, 0.9112548830, 0.1187744141, 0.0260009766, 0.9058837893 },
+ { 0.3909912110, 0.8299560549, 0.1866455079, 0.0362548828, 0.9937744143, 0.9635009768, 0.0933837891 },
+ { 0.2659912110, 0.4549560548, 0.3741455079, 0.5206298829, 0.3218994141, 0.2095947266, 0.7691650392 },
+ { 0.7659912111, 0.9549560549, 0.6241455080, 0.3956298829, 0.6968994142, 0.7720947267, 0.2066650391 },
+ { 0.5159912111, 0.2049560547, 0.0616455078, 0.6300048830, 0.4625244142, 0.1431884766, 0.8355712893 },
+ { 0.0159912109, 0.7049560549, 0.8116455080, 0.2550048829, 0.5875244142, 0.8306884768, 0.1480712891 },
+ { 0.0238037109, 0.1190185547, 0.0186767578, 0.1827392579, 0.9136962893, 0.5960693361, 0.2923583985 },
+ { 0.5238037111, 0.6190185548, 0.7686767580, 0.8077392580, 0.0386962891, 0.4085693360, 0.7298583986 },
+ { 0.7738037111, 0.3690185548, 0.3311767579, 0.0421142578, 0.8043212892, 0.5374755861, 0.3587646485 },
+ { 0.2738037110, 0.8690185549, 0.5811767579, 0.9171142580, 0.1793212891, 0.4749755860, 0.6712646486 },
+ { 0.3988037110, 0.4940185548, 0.8936767580, 0.4014892579, 0.5074462892, 0.7288818361, 0.4720458985 },
+ { 0.8988037111, 0.9940185549, 0.1436767578, 0.5264892579, 0.3824462892, 0.2913818360, 0.5345458986 },
+ { 0.6488037111, 0.2440185547, 0.7061767580, 0.2608642579, 0.6480712892, 0.6702880861, 0.4134521485 },
+ { 0.1488037110, 0.7440185549, 0.4561767579, 0.6358642580, 0.2730712891, 0.3577880860, 0.6009521486 },
+ { 0.2113037110, 0.3065185548, 0.5030517579, 0.6202392580, 0.1011962891, 0.8616943361, 0.2454833985 },
+ { 0.7113037111, 0.8065185549, 0.2530517579, 0.4952392579, 0.9761962893, 0.1741943360, 0.8079833986 },
+ { 0.9613037112, 0.0565185547, 0.8155517580, 0.7296142580, 0.2418212891, 0.8031005861, 0.1868896485 },
+ { 0.4613037110, 0.5565185548, 0.0655517578, 0.3546142579, 0.8668212893, 0.2406005860, 0.8743896486 },
+ { 0.3363037110, 0.1815185547, 0.3780517579, 0.8389892580, 0.4449462892, 0.9945068362, 0.0501708984 },
+ { 0.8363037111, 0.6815185548, 0.6280517580, 0.2139892579, 0.5699462892, 0.0570068360, 0.9876708987 },
+ { 0.5863037111, 0.4315185548, 0.1905517579, 0.9483642580, 0.3355712891, 0.9359130862, 0.1165771485 },
+ { 0.0863037110, 0.9315185549, 0.9405517580, 0.0733642578, 0.7105712892, 0.1234130860, 0.9290771487 },
+ { 0.1175537110, 0.4002685548, 0.2999267579, 0.2901611329, 0.1617431641, 0.0023193359, 0.6986083986 },
+ { 0.6175537111, 0.9002685549, 0.5499267579, 0.6651611330, 0.7867431642, 0.9398193362, 0.2611083985 },
+ { 0.8675537111, 0.1502685547, 0.1124267578, 0.4307861329, 0.0523681641, 0.0687255860, 0.6400146486 },
+ { 0.3675537110, 0.6502685548, 0.8624267580, 0.5557861329, 0.9273681643, 0.8812255861, 0.3275146485 },
+ { 0.4925537111, 0.0252685547, 0.6749267580, 0.0089111328, 0.2554931641, 0.1351318360, 0.5032958986 },
+ { 0.9925537112, 0.5252685548, 0.4249267579, 0.8839111330, 0.6304931642, 0.8226318361, 0.4407958985 },
+ { 0.7425537111, 0.2752685548, 0.9874267580, 0.1495361328, 0.3961181642, 0.2015380860, 0.5697021486 },
+ { 0.2425537110, 0.7752685549, 0.2374267579, 0.7745361330, 0.5211181642, 0.7640380861, 0.3822021485 },
+ { 0.1800537110, 0.2127685547, 0.7843017580, 0.9776611330, 0.8492431643, 0.2679443360, 0.7767333986 },
+ { 0.6800537111, 0.7127685549, 0.0343017578, 0.1026611328, 0.2242431641, 0.7054443361, 0.2142333985 },
+ { 0.9300537112, 0.4627685548, 0.5968017580, 0.8682861330, 0.9898681643, 0.3343505860, 0.8431396486 },
+ { 0.4300537110, 0.9627685549, 0.3468017579, 0.2432861329, 0.1148681641, 0.6468505861, 0.1556396485 },
+ { 0.3050537110, 0.3377685548, 0.1593017578, 0.6964111330, 0.6929931642, 0.4007568360, 0.9564208987 },
+ { 0.8050537111, 0.8377685549, 0.9093017580, 0.3214111329, 0.3179931641, 0.5882568361, 0.0189208984 },
+ { 0.5550537111, 0.0877685547, 0.4718017579, 0.5870361329, 0.5836181642, 0.4671630860, 0.8978271486 },
+ { 0.0550537110, 0.5877685548, 0.7218017580, 0.4620361329, 0.4586181642, 0.5296630861, 0.0853271485 },
+ { 0.0394287109, 0.3533935548, 0.8350830080, 0.7647705080, 0.2847900391, 0.6622314455, 0.6671142580 },
+ { 0.5394287111, 0.8533935549, 0.0850830078, 0.1397705078, 0.6597900392, 0.3497314454, 0.3546142579 },
+ { 0.7894287111, 0.1033935547, 0.5225830079, 0.9053955080, 0.4254150392, 0.7208251955, 0.7335205080 },
+ { 0.2894287110, 0.6033935548, 0.2725830079, 0.0303955078, 0.5504150392, 0.2833251954, 0.2960205079 }
+};
+
+
+// Spatial dimension: 16
+// N: 100
+// Vectors skipped: 4095
+static const double niederreiter_base2_16_100[100][16] =
+{
+ { 0.0003662109, 0.4705810548, 0.6358642580, 0.9561767580, 0.6715087892, 0.9793701174, 0.6053466798, 0.1983642579, 0.2217731476, 0.3769855500, 0.5390644075, 0.4707050325, 0.2744159699, 0.9942340853, 0.5396728517, 0.0626220703 },
+ { 0.5003662111, 0.9705810549, 0.3858642579, 0.0811767578, 0.2965087891, 0.0418701172, 0.4178466798, 0.7608642580, 0.7530231478, 0.5957355501, 0.4453144075, 0.5019550325, 0.7431659700, 0.0254840851, 0.4615478517, 0.9219970705 },
+ { 0.7503662111, 0.2205810547, 0.9483642580, 0.8155517580, 0.5621337892, 0.9207763674, 0.5467529298, 0.1397705078, 0.1895465851, 0.4092121125, 0.5087909700, 0.4404315950, 0.3046894074, 0.9639606478, 0.5555419923, 0.0784912110 },
+ { 0.2503662110, 0.7205810549, 0.1983642579, 0.1905517579, 0.4371337892, 0.1082763672, 0.4842529298, 0.8272705080, 0.7832965853, 0.5654621126, 0.4775409700, 0.5341815950, 0.7109394075, 0.0577106476, 0.4461669923, 0.9066162111 },
+ { 0.3753662110, 0.0955810547, 0.2608642579, 0.7374267580, 0.7652587892, 0.8465576174, 0.6600341798, 0.0030517578, 0.1573200226, 0.4375324250, 0.6035175325, 0.3750019074, 0.3701190949, 0.8985309603, 0.5079345704, 0.0943603516 },
+ { 0.8753662111, 0.5955810548, 0.5108642579, 0.3624267579, 0.1402587891, 0.1590576172, 0.3475341798, 0.9405517580, 0.8135700228, 0.5312824251, 0.3847675324, 0.5937519075, 0.6513690950, 0.1172809601, 0.4923095704, 0.8912353518 },
+ { 0.6253662111, 0.3455810548, 0.0733642578, 0.5968017580, 0.9058837893, 0.7879638674, 0.7264404299, 0.0694580078, 0.1250934601, 0.4697589875, 0.5732440950, 0.4072284699, 0.3378925324, 0.9307575228, 0.5238037111, 0.1102294922 },
+ { 0.1253662110, 0.8455810549, 0.8233642580, 0.4718017579, 0.0308837891, 0.2254638672, 0.2889404298, 0.8819580080, 0.8438434603, 0.5010089875, 0.4169940949, 0.5634784700, 0.6816425325, 0.0870075226, 0.4769287110, 0.8758544924 },
+ { 0.1878662110, 0.1580810547, 0.1514892578, 0.2686767579, 0.3590087891, 0.7449951174, 0.9334716799, 0.3389892579, 0.1006793976, 0.2871418000, 0.6367206575, 0.2558612824, 0.4658222200, 0.8106403353, 0.6031494142, 0.0010986328 },
+ { 0.6878662111, 0.6580810548, 0.9014892580, 0.6436767580, 0.7340087892, 0.3074951173, 0.1209716797, 0.6514892580, 0.8819293978, 0.6933918001, 0.3554706574, 0.7246112825, 0.5595722200, 0.2168903351, 0.4000244142, 0.9854736330 },
+ { 0.9378662112, 0.4080810548, 0.4639892579, 0.3780517579, 0.4996337892, 0.6864013673, 0.9998779299, 0.2803955079, 0.0684528351, 0.2568683625, 0.6689472200, 0.2880878449, 0.4960956575, 0.7803668978, 0.6190185548, 0.0169677734 },
+ { 0.4378662110, 0.9080810549, 0.7139892580, 0.5030517579, 0.6246337892, 0.3739013673, 0.0623779297, 0.7178955080, 0.9122028353, 0.7256183626, 0.3251972199, 0.6943378450, 0.5273456575, 0.2491168976, 0.3846435548, 0.9700927737 },
+ { 0.3128662110, 0.2830810548, 0.7764892580, 0.0499267578, 0.2027587891, 0.6121826173, 0.8631591799, 0.3936767579, 0.0362262726, 0.3476886750, 0.7011737825, 0.3476581574, 0.4365253450, 0.8399372103, 0.5714111329, 0.0328369141 },
+ { 0.8128662111, 0.7830810549, 0.0264892578, 0.9249267580, 0.8277587893, 0.4246826173, 0.1756591797, 0.5811767579, 0.9424762728, 0.6289386751, 0.2949237824, 0.6289081575, 0.5927753450, 0.1836872101, 0.4307861329, 0.9547119143 },
+ { 0.5628662111, 0.0330810547, 0.5889892579, 0.1593017578, 0.0933837891, 0.5535888673, 0.8045654299, 0.4600830079, 0.0039997101, 0.3174152375, 0.7334003450, 0.3173847199, 0.4042987824, 0.8721637728, 0.5872802736, 0.0487060547 },
+ { 0.0628662110, 0.5330810548, 0.3389892579, 0.7843017580, 0.9683837893, 0.4910888673, 0.2420654297, 0.5225830079, 0.9727497103, 0.6611652376, 0.2646503449, 0.6611347200, 0.6230487825, 0.1534137726, 0.4154052735, 0.9393310549 },
+ { 0.0941162110, 0.0018310547, 0.9171142580, 0.5635986329, 0.4195556642, 0.3856201173, 0.3865966798, 0.9796142580, 0.4483356477, 0.1972980500, 0.8125019075, 0.0410175324, 0.1728534699, 0.6114215852, 0.6666259767, 0.2052001954 },
+ { 0.5941162111, 0.5018310548, 0.1671142579, 0.4385986329, 0.5445556642, 0.5731201173, 0.5740966798, 0.0421142578, 0.5420856477, 0.7910480501, 0.1562519074, 0.9472675326, 0.8291034700, 0.3926715852, 0.3385009766, 0.7833251955 },
+ { 0.8441162111, 0.2518310547, 0.7296142580, 0.7042236330, 0.3101806641, 0.4520263673, 0.4530029298, 0.9210205080, 0.4786090852, 0.2295246125, 0.8447284700, 0.0107440949, 0.1406269074, 0.5811481477, 0.6824951173, 0.1898193360 },
+ { 0.3441162110, 0.7518310549, 0.4796142579, 0.3292236329, 0.6851806642, 0.5145263673, 0.5155029298, 0.1085205078, 0.5098590852, 0.7607746126, 0.1259784699, 0.9794940951, 0.8593769075, 0.4248981477, 0.3231201173, 0.7991943361 },
+ { 0.4691162110, 0.3768310548, 0.0421142578, 0.8448486330, 0.0133056641, 0.2528076172, 0.3162841798, 0.7843017580, 0.3838825227, 0.1328449250, 0.7519550325, 0.0703144074, 0.2060565949, 0.5157184602, 0.6348876955, 0.2369384766 },
+ { 0.9691162112, 0.8768310549, 0.7921142580, 0.2198486329, 0.8883056643, 0.6903076173, 0.6287841798, 0.2218017579, 0.6026325227, 0.8515949251, 0.2207050324, 0.9140644076, 0.7998065950, 0.4844684602, 0.3692626954, 0.7525634767 },
+ { 0.7191162111, 0.1268310547, 0.3546142579, 0.9854736330, 0.1539306641, 0.3192138673, 0.2576904297, 0.8507080080, 0.4141559602, 0.1650714875, 0.7841815950, 0.1025409699, 0.2363300324, 0.5479450227, 0.6507568361, 0.2215576172 },
+ { 0.2191162110, 0.6268310548, 0.6046142580, 0.1104736328, 0.7789306642, 0.6317138673, 0.6951904298, 0.1632080079, 0.5704059602, 0.8213214876, 0.1904315949, 0.8837909701, 0.7675800325, 0.4541950227, 0.3538818360, 0.7684326174 },
+ { 0.1566162110, 0.3143310548, 0.4327392579, 0.1260986328, 0.6070556642, 0.1512451172, 0.0897216797, 0.6202392580, 0.3272418977, 0.1074543000, 0.9726581576, 0.2011737824, 0.1142597199, 0.6778278352, 0.7301025392, 0.1436767578 },
+ { 0.6566162111, 0.8143310549, 0.6827392580, 0.7510986330, 0.4820556642, 0.8387451174, 0.9022216799, 0.4327392579, 0.6709918977, 0.8887043001, 0.0039081573, 0.7949237825, 0.8955097201, 0.3340778352, 0.2769775391, 0.8468017580 },
+ { 0.9066162111, 0.0643310547, 0.2452392579, 0.0167236328, 0.7476806642, 0.2176513672, 0.0311279297, 0.5616455079, 0.3575153352, 0.0771808624, 0.9423847201, 0.2334003449, 0.0820331574, 0.6475543977, 0.7459716799, 0.1282958985 },
+ { 0.4066162110, 0.5643310548, 0.9952392580, 0.8917236330, 0.3726806641, 0.7801513674, 0.9686279299, 0.4991455079, 0.6387653352, 0.9209308626, 0.0361347199, 0.7646503450, 0.9257831576, 0.3663043977, 0.2615966797, 0.8626708986 },
+ { 0.2816162110, 0.1893310547, 0.5577392579, 0.4073486329, 0.9508056643, 0.0184326172, 0.1444091797, 0.6749267580, 0.2627887726, 0.0430011749, 0.9121112826, 0.1679706574, 0.0224628449, 0.7071247102, 0.6983642580, 0.1754150391 },
+ { 0.7816162111, 0.6893310548, 0.3077392579, 0.5323486329, 0.0758056641, 0.9559326174, 0.8319091799, 0.3624267579, 0.7315387728, 0.9492511751, 0.0683612824, 0.8242206575, 0.9912128451, 0.3008747102, 0.3077392579, 0.8160400393 },
+ { 0.5316162111, 0.4393310548, 0.8702392580, 0.2979736329, 0.8414306643, 0.0848388672, 0.2108154297, 0.7413330080, 0.2930622102, 0.0127277374, 0.8818378451, 0.1376972199, 0.0527362824, 0.7393512728, 0.7142333986, 0.1600341797 },
+ { 0.0316162109, 0.9393310549, 0.1202392578, 0.6729736330, 0.2164306641, 0.8973388674, 0.7733154299, 0.3038330079, 0.6993122102, 0.9814777377, 0.1005878449, 0.8564472200, 0.9589862826, 0.2706012726, 0.2923583985, 0.8319091799 },
+ { 0.0472412109, 0.2362060547, 0.4522705079, 0.1007080078, 0.0426025391, 0.7955322267, 0.4801025392, 0.7025146486, 0.6748981477, 0.7988605501, 0.2421894074, 0.6113300325, 0.5712909700, 0.1973590851, 0.7935791017, 0.3477783204 },
+ { 0.5472412111, 0.7362060549, 0.7022705080, 0.9757080080, 0.9176025393, 0.2330322266, 0.5426025392, 0.2650146485, 0.3311481477, 0.2051105500, 0.7734394075, 0.3925800324, 0.4150409699, 0.7911090853, 0.2154541016, 0.6446533205 },
+ { 0.7972412111, 0.4862060548, 0.1397705078, 0.2413330079, 0.1832275391, 0.8541259768, 0.4215087892, 0.6361083986, 0.6426715852, 0.7685871126, 0.2119159699, 0.5810565950, 0.6015644075, 0.2295856476, 0.8094482424, 0.3636474610 },
+ { 0.2972412110, 0.9862060549, 0.8897705080, 0.8663330080, 0.8082275393, 0.1666259766, 0.6090087892, 0.3236083985, 0.3614215852, 0.2373371125, 0.8056659700, 0.4248065949, 0.3828144074, 0.7608356478, 0.2000732422, 0.6292724611 },
+ { 0.4222412110, 0.3612060548, 0.5772705079, 0.3194580079, 0.3863525392, 0.9127197268, 0.2847900391, 0.5072021486, 0.7354450228, 0.8594074251, 0.1816425324, 0.5156269075, 0.5419940950, 0.1641559601, 0.7618408205, 0.3170166016 },
+ { 0.9222412112, 0.8612060549, 0.3272705079, 0.6944580080, 0.5113525392, 0.1002197266, 0.7222900392, 0.4447021485, 0.2666950226, 0.1406574250, 0.8378925325, 0.4843769075, 0.4482440950, 0.8204059603, 0.2462158204, 0.6763916017 },
+ { 0.6722412111, 0.1112060547, 0.7647705080, 0.4600830079, 0.2769775391, 0.9713134768, 0.3511962891, 0.5657958986, 0.7032184602, 0.8291339876, 0.1513690949, 0.5478534700, 0.5097675325, 0.1338825226, 0.7777099611, 0.3328857423 },
+ { 0.1722412110, 0.6112060548, 0.0147705078, 0.5850830079, 0.6519775392, 0.0338134766, 0.6636962892, 0.3782958985, 0.2969684602, 0.1728839875, 0.8701190951, 0.4541034700, 0.4785175325, 0.8526325228, 0.2308349610, 0.6610107423 },
+ { 0.2347412110, 0.4237060548, 0.9678955080, 0.6632080080, 0.9801025393, 0.5611572267, 0.0582275391, 0.8431396486, 0.5538043977, 0.8965168001, 0.0898456574, 0.6464862825, 0.6376972200, 0.0137653351, 0.8570556643, 0.2862548829 },
+ { 0.7347412111, 0.9237060549, 0.2178955079, 0.2882080079, 0.1051025391, 0.4986572267, 0.9957275393, 0.1556396485, 0.4600543977, 0.1152668000, 0.9335956576, 0.3652362824, 0.3564472199, 0.9825153353, 0.1539306641, 0.7081298830 },
+ { 0.9847412112, 0.1737060547, 0.6553955080, 0.5538330079, 0.8707275393, 0.6197509767, 0.1246337891, 0.7767333986, 0.5215778352, 0.9287433626, 0.1220722199, 0.6787128450, 0.6679706575, 0.0459918976, 0.8729248049, 0.3021240235 },
+ { 0.4847412111, 0.6737060548, 0.4053955079, 0.4288330079, 0.2457275391, 0.4322509767, 0.9371337893, 0.2142333985, 0.4903278352, 0.0849933624, 0.9033222201, 0.3349628449, 0.3242206574, 0.9522418978, 0.1385498047, 0.6927490236 },
+ { 0.3597412110, 0.0487060547, 0.0928955078, 0.8819580080, 0.5738525392, 0.6783447267, 0.2379150391, 0.8978271486, 0.6143512727, 0.9570636751, 0.0292987824, 0.7382831575, 0.7334003450, 0.1055622101, 0.8253173830, 0.2554931641 },
+ { 0.8597412111, 0.5487060548, 0.8428955080, 0.0069580078, 0.4488525392, 0.3658447266, 0.8004150392, 0.0853271485, 0.3956012727, 0.0508136749, 0.9980487826, 0.2695331574, 0.2646503449, 0.8868122103, 0.1846923829, 0.7398681642 },
+ { 0.6097412111, 0.2987060548, 0.2803955079, 0.7725830080, 0.7144775392, 0.7369384767, 0.1793212891, 0.9564208987, 0.5821247102, 0.9892902377, 0.0615253449, 0.7080097200, 0.7011737825, 0.0752887726, 0.8411865236, 0.2713623048 },
+ { 0.1097412110, 0.7987060549, 0.5303955079, 0.1475830078, 0.3394775391, 0.2994384766, 0.8668212893, 0.0189208984, 0.4258747102, 0.0205402374, 0.9677753451, 0.3017597199, 0.2949237824, 0.9190387728, 0.1693115235, 0.7244873049 },
+ { 0.0784912110, 0.2674560547, 0.2335205079, 0.4893798829, 0.7906494142, 0.3267822266, 0.5113525392, 0.4837646486, 0.9014606478, 0.6191730501, 0.3906269074, 0.9316425326, 0.9697284701, 0.3145465852, 0.9205322268, 0.4903564454 },
+ { 0.5784912111, 0.7674560549, 0.9835205080, 0.6143798830, 0.1656494141, 0.6392822267, 0.4488525392, 0.5462646486, 0.1202106476, 0.4004230500, 0.6093769075, 0.0878925324, 0.0009784698, 0.6582965852, 0.0924072266, 0.5059814454 },
+ { 0.8284912111, 0.0174560547, 0.4210205079, 0.3487548829, 0.9312744143, 0.2603759766, 0.5777587892, 0.4173583985, 0.9317340853, 0.5888996126, 0.4228534699, 0.9013690951, 0.9375019076, 0.3467731477, 0.9364013674, 0.4749755860 },
+ { 0.3284912110, 0.5174560548, 0.6710205080, 0.7237548830, 0.0562744141, 0.6978759767, 0.3902587892, 0.6048583986, 0.0879840851, 0.4326496125, 0.5791034700, 0.1201190949, 0.0312519074, 0.6280231477, 0.0770263672, 0.5218505861 },
+ { 0.4534912110, 0.1424560547, 0.8585205080, 0.2081298829, 0.6343994142, 0.4439697267, 0.6910400392, 0.2884521485, 0.9620075228, 0.5547199251, 0.4550800325, 0.9609394076, 0.8779315951, 0.2813434601, 0.8887939455, 0.4595947267 },
+ { 0.9534912112, 0.6424560548, 0.1085205078, 0.8331298830, 0.2593994141, 0.5064697267, 0.2535400391, 0.7259521486, 0.0557575226, 0.4609699250, 0.5488300325, 0.0546894074, 0.0966815949, 0.6875934602, 0.1231689453, 0.5377197267 },
+ { 0.7034912111, 0.3924560548, 0.5460205079, 0.0675048828, 0.5250244142, 0.3775634767, 0.6324462892, 0.3470458985, 0.9922809603, 0.5244464875, 0.4873065950, 0.9931659701, 0.9082050326, 0.2510700226, 0.9046630861, 0.4442138673 },
+ { 0.2034912110, 0.8924560549, 0.2960205079, 0.9425048830, 0.4000244142, 0.5650634767, 0.3199462891, 0.6595458986, 0.0235309601, 0.4931964875, 0.5185565950, 0.0244159699, 0.0644550324, 0.7198200228, 0.1077880860, 0.5535888673 },
+ { 0.1409912110, 0.0799560547, 0.7491455080, 0.8018798830, 0.2281494141, 0.0924072266, 0.9644775393, 0.1243896485, 0.7803668978, 0.7168293001, 0.3007831574, 0.8417987825, 0.7861347200, 0.3809528352, 0.9840087893, 0.4288330079 },
+ { 0.6409912111, 0.5799560548, 0.4991455079, 0.1768798829, 0.8531494143, 0.9049072268, 0.0269775391, 0.9368896487, 0.2491168976, 0.3105793000, 0.7070331575, 0.1855487824, 0.1923847199, 0.5997028352, 0.0308837891, 0.5694580079 },
+ { 0.8909912111, 0.3299560548, 0.9366455080, 0.9112548830, 0.1187744141, 0.0260009766, 0.9058837893, 0.0579833985, 0.8106403353, 0.7490558626, 0.2705097199, 0.8740253451, 0.7539081575, 0.4131793977, 0.9998779299, 0.4134521485 },
+ { 0.3909912110, 0.8299560549, 0.1866455079, 0.0362548828, 0.9937744143, 0.9635009768, 0.0933837891, 0.9954833987, 0.2168903351, 0.2803058625, 0.7392597200, 0.1552753449, 0.2226581574, 0.5694293977, 0.0155029297, 0.5853271486 },
+ { 0.2659912110, 0.4549560548, 0.3741455079, 0.5206298829, 0.3218994141, 0.2095947266, 0.7691650392, 0.1790771485, 0.8409137728, 0.6523761751, 0.3652362824, 0.8085956575, 0.8193378450, 0.4727497102, 0.9522705080, 0.3980712892 },
+ { 0.7659912111, 0.9549560549, 0.6241455080, 0.3956298829, 0.6968994142, 0.7720947267, 0.2066650391, 0.8665771486, 0.1846637726, 0.3711261750, 0.6464862825, 0.2148456574, 0.1630878449, 0.5039997102, 0.0616455078, 0.6011962892 },
+ { 0.5159912111, 0.2049560547, 0.0616455078, 0.6300048830, 0.4625244142, 0.1431884766, 0.8355712893, 0.2376708985, 0.8711872103, 0.6846027376, 0.3349628449, 0.7783222200, 0.8496112825, 0.4424762727, 0.9681396487, 0.3826904298 },
+ { 0.0159912109, 0.7049560549, 0.8116455080, 0.2550048829, 0.5875244142, 0.8306884768, 0.1480712891, 0.8001708986, 0.1524372101, 0.3408527375, 0.6787128450, 0.2470722199, 0.1308612824, 0.5362262727, 0.0462646484, 0.6170654298 },
+ { 0.0238037109, 0.1190185547, 0.0186767578, 0.1827392579, 0.9136962893, 0.5960693361, 0.2923583985, 0.1285400391, 0.0645160675, 0.2207050324, 0.8828449251, 0.6894855501, 0.9297199251, 0.4326801301, 0.0474853516, 0.5079345704 },
+ { 0.5238037111, 0.6190185548, 0.7686767580, 0.8077392580, 0.0386962891, 0.4085693360, 0.7298583986, 0.8160400393, 0.9082660677, 0.7519550325, 0.1015949250, 0.2832355500, 0.0859699249, 0.5889301301, 0.9381103518, 0.4923095704 },
+ { 0.7738037111, 0.3690185548, 0.3311767579, 0.0421142578, 0.8043212892, 0.5374755861, 0.3587646485, 0.1949462891, 0.0967426300, 0.1904315949, 0.9150714876, 0.7217121126, 0.8994464876, 0.4004535676, 0.0321044922, 0.5238037111 },
+ { 0.2738037110, 0.8690185549, 0.5811767579, 0.9171142580, 0.1793212891, 0.4749755860, 0.6712646486, 0.7574462892, 0.8779926302, 0.7841815950, 0.0713214874, 0.2529621125, 0.1181964875, 0.6192035676, 0.9539794924, 0.4769287110 },
+ { 0.3988037110, 0.4940185548, 0.8936767580, 0.4014892579, 0.5074462892, 0.7288818361, 0.4720458985, 0.0738525391, 0.0000629425, 0.1562519074, 0.9472980501, 0.6562824251, 0.9629230502, 0.4619770051, 0.0157470703, 0.5396728517 },
+ { 0.8988037111, 0.9940185549, 0.1436767578, 0.5264892579, 0.3824462892, 0.2913818360, 0.5345458986, 0.8863525393, 0.9688129427, 0.8125019075, 0.0410480499, 0.3125324250, 0.0566730499, 0.5557270051, 0.9688720705, 0.4615478517 },
+ { 0.6488037111, 0.2440185547, 0.7061767580, 0.2608642579, 0.6480712892, 0.6702880861, 0.4134521485, 0.0152587891, 0.0322895050, 0.1259784699, 0.9795246127, 0.6260089876, 0.9951496127, 0.4922504426, 0.0003662109, 0.5555419923 },
+ { 0.1488037110, 0.7440185549, 0.4561767579, 0.6358642580, 0.2730712891, 0.3577880860, 0.6009521486, 0.9527587893, 0.9385395052, 0.8447284700, 0.0107746124, 0.3447589875, 0.0263996124, 0.5235004426, 0.9847412112, 0.4461669923 },
+ { 0.2113037110, 0.3065185548, 0.5030517579, 0.6202392580, 0.1011962891, 0.8616943361, 0.2454833985, 0.2691650391, 0.1934223175, 0.0683612824, 0.7930011751, 0.5371418001, 0.8711261751, 0.3740863801, 0.1109619141, 0.5714111329 },
+ { 0.7113037111, 0.8065185549, 0.2530517579, 0.4952392579, 0.9761962893, 0.1741943360, 0.8079833986, 0.7066650392, 0.7871723177, 0.9121112826, 0.1992511750, 0.4433918000, 0.1523761750, 0.6553363802, 0.8765869143, 0.4307861329 },
+ { 0.9613037112, 0.0565185547, 0.8155517580, 0.7296142580, 0.2418212891, 0.8031005861, 0.1868896485, 0.3355712891, 0.2256488801, 0.1005878449, 0.7627277376, 0.5068683625, 0.8408527376, 0.3418598176, 0.0955810547, 0.5872802736 },
+ { 0.4613037110, 0.5565185548, 0.0655517578, 0.3546142579, 0.8668212893, 0.2406005860, 0.8743896486, 0.6480712892, 0.7568988802, 0.8818378451, 0.2314777375, 0.4756183625, 0.1846027375, 0.6856098177, 0.8924560549, 0.4154052735 },
+ { 0.3363037110, 0.1815185547, 0.3780517579, 0.8389892580, 0.4449462892, 0.9945068362, 0.0501708984, 0.4644775392, 0.1289691925, 0.0039081573, 0.8574543001, 0.5664386751, 0.7793293001, 0.2783832551, 0.0792236328, 0.6031494142 },
+ { 0.8363037111, 0.6815185548, 0.6280517580, 0.2139892579, 0.5699462892, 0.0570068360, 0.9876708987, 0.5269775392, 0.8477191927, 0.9726581576, 0.1387043000, 0.4101886750, 0.2480793000, 0.7471332552, 0.9073486330, 0.4000244142 },
+ { 0.5863037111, 0.4315185548, 0.1905517579, 0.9483642580, 0.3355712891, 0.9359130862, 0.1165771485, 0.4058837892, 0.1611957550, 0.0361347199, 0.8271808626, 0.5986652376, 0.8115558626, 0.3086566926, 0.0638427735, 0.6190185548 },
+ { 0.0863037110, 0.9315185549, 0.9405517580, 0.0733642578, 0.7105712892, 0.1234130860, 0.9290771487, 0.5933837892, 0.8174457552, 0.9423847201, 0.1709308625, 0.3799152375, 0.2178058625, 0.7149066927, 0.9232177737, 0.3846435548 },
+ { 0.1175537110, 0.4002685548, 0.2999267579, 0.2901611329, 0.1617431641, 0.0023193359, 0.6986083986, 0.9097900393, 0.3535785676, 0.4160175324, 0.7187824251, 0.7597980501, 0.5156574250, 0.0498676300, 0.1744384766, 0.6505126955 },
+ { 0.6175537111, 0.9002685549, 0.5499267579, 0.6651611330, 0.7867431642, 0.9398193362, 0.2611083985, 0.0972900391, 0.6348285677, 0.5722675325, 0.2500324250, 0.2285480500, 0.4844074250, 0.9561176302, 0.8150634768, 0.3536376954 },
+ { 0.8675537111, 0.1502685547, 0.1124267578, 0.4307861329, 0.0523681641, 0.0687255860, 0.6400146486, 0.9761962893, 0.3233051301, 0.3857440949, 0.6885089876, 0.7920246126, 0.5478839876, 0.0176410675, 0.1590576172, 0.6351318361 },
+ { 0.3675537110, 0.6502685548, 0.8624267580, 0.5557861329, 0.9273681643, 0.8812255861, 0.3275146485, 0.0386962891, 0.6670551302, 0.6044940950, 0.2822589875, 0.1982746125, 0.4541339875, 0.9863910677, 0.8309326174, 0.3695068360 },
+ { 0.4925537111, 0.0252685547, 0.6749267580, 0.0089111328, 0.2554931641, 0.1351318360, 0.5032958986, 0.8551025393, 0.2891254426, 0.4765644075, 0.6582355501, 0.8515949251, 0.6113605501, 0.0791645050, 0.1427001953, 0.6822509767 },
+ { 0.9925537112, 0.5252685548, 0.4249267579, 0.8839111330, 0.6304931642, 0.8226318361, 0.4407958985, 0.1676025391, 0.6953754427, 0.5078144075, 0.3144855500, 0.1328449250, 0.3926105500, 0.9229145052, 0.8458251955, 0.3228759766 },
+ { 0.7425537111, 0.2752685548, 0.9874267580, 0.1495361328, 0.3961181642, 0.2015380860, 0.5697021486, 0.7965087892, 0.2588520051, 0.4462909700, 0.6279621126, 0.8213214876, 0.5810871126, 0.1094379425, 0.1273193360, 0.6668701173 },
+ { 0.2425537110, 0.7752685549, 0.2374267579, 0.7745361330, 0.5211181642, 0.7640380861, 0.3822021485, 0.2340087891, 0.7276020052, 0.5400409700, 0.3467121125, 0.1650714875, 0.4248371125, 0.8906879427, 0.8616943361, 0.3387451173 },
+ { 0.1800537110, 0.2127685547, 0.7843017580, 0.9776611330, 0.8492431643, 0.2679443360, 0.7767333986, 0.5504150392, 0.4824848176, 0.2636737824, 0.5664386751, 0.9824543002, 0.7070636751, 0.2412738801, 0.2379150391, 0.7139892580 },
+ { 0.6800537111, 0.7127685549, 0.0343017578, 0.1026611328, 0.2242431641, 0.7054443361, 0.2142333985, 0.4879150392, 0.5137348176, 0.7324237825, 0.4101886750, 0.0137042999, 0.3008136750, 0.7725238802, 0.7535400392, 0.2921142579 },
+ { 0.9300537112, 0.4627685548, 0.5968017580, 0.8682861330, 0.9898681643, 0.3343505860, 0.8431396486, 0.6168212892, 0.4522113801, 0.2959003449, 0.5986652376, 0.9521808626, 0.7392902376, 0.2090473176, 0.2225341797, 0.6986083986 },
+ { 0.4300537110, 0.9627685549, 0.3468017579, 0.2432861329, 0.1148681641, 0.6468505861, 0.1556396485, 0.4293212892, 0.5459613801, 0.7021503450, 0.3799152375, 0.0459308624, 0.2705402375, 0.8027973177, 0.7694091799, 0.3079833985 },
+ { 0.3050537110, 0.3377685548, 0.1593017578, 0.6964111330, 0.6929931642, 0.4007568360, 0.9564208987, 0.7457275392, 0.4180316926, 0.3242206574, 0.5058918000, 0.8867511751, 0.6777668001, 0.1455707550, 0.2061767579, 0.7457275392 },
+ { 0.8050537111, 0.8377685549, 0.9093017580, 0.3214111329, 0.3179931641, 0.5882568361, 0.0189208984, 0.3082275391, 0.5742816926, 0.6679706575, 0.4746418000, 0.1055011750, 0.3340168000, 0.8643207552, 0.7843017580, 0.2613525391 },
+ { 0.5550537111, 0.0877685547, 0.4718017579, 0.5870361329, 0.5836181642, 0.4671630860, 0.8978271486, 0.6871337892, 0.3877582551, 0.3564472199, 0.5381183626, 0.9189777376, 0.6474933626, 0.1758441925, 0.1907958985, 0.7303466799 },
+ { 0.0550537110, 0.5877685548, 0.7218017580, 0.4620361329, 0.4586181642, 0.5296630861, 0.0853271485, 0.3746337891, 0.6065082551, 0.6376972200, 0.4443683625, 0.0752277374, 0.3662433625, 0.8320941927, 0.8001708986, 0.2772216798 },
+ { 0.0394287109, 0.3533935548, 0.8350830080, 0.7647705080, 0.2847900391, 0.6622314455, 0.6671142580, 0.6326904298, 0.5176410676, 0.5800800325, 0.3359699250, 0.3301105500, 0.2265949250, 0.6358051302, 0.3013916016, 0.7930908205 },
+ { 0.5394287111, 0.8533935549, 0.0850830078, 0.1397705078, 0.6597900392, 0.3497314454, 0.3546142579, 0.3201904298, 0.4863910676, 0.4238300324, 0.6797199251, 0.6738605501, 0.7578449251, 0.3545551301, 0.6920166017, 0.2149658204 },
+ { 0.7894287111, 0.1033935547, 0.5225830079, 0.9053955080, 0.4254150392, 0.7208251955, 0.7335205080, 0.6912841798, 0.5498676301, 0.6123065950, 0.3681964875, 0.3623371125, 0.1963214875, 0.6660785677, 0.2860107423, 0.8089599611 },
+ { 0.2894287110, 0.6033935548, 0.2725830079, 0.0303955078, 0.5504150392, 0.2833251954, 0.2960205079, 0.2537841797, 0.4561176301, 0.3935565949, 0.6494464876, 0.6435871126, 0.7900714876, 0.3223285676, 0.7078857424, 0.1995849610 }
+};
+
+
+QRNG_VALIDATION_TEST_FUNCTIONS(niederreiter_base2)
+QRNG_VALIDATION_TEST_DISCARD(niederreiter_base2)
+
+BOOST_AUTO_TEST_CASE( check_generator_limits )
+{
+ test_niederreiter_base2_max_seed();
+ test_niederreiter_base2_max_discard();
+ test_niederreiter_base2_max_dimension(BOOST_RANDOM_NIEDERREITER_BASE2_MAX_DIMENSION);
+}
+
+BOOST_AUTO_TEST_CASE( validate_niederreiter_base2 )
+{
+ test_niederreiter_base2_values(niederreiter_base2_02_100, 4095);
+ test_niederreiter_base2_values(niederreiter_base2_07_100, 4095);
+ test_niederreiter_base2_values(niederreiter_base2_16_100, 4095);
+}
+
+BOOST_AUTO_TEST_CASE( validate_niederreiter_base2_seed )
+{
+ test_niederreiter_base2_seed(niederreiter_base2_02_100, 4095);
+ test_niederreiter_base2_seed(niederreiter_base2_07_100, 4095);
+ test_niederreiter_base2_seed(niederreiter_base2_16_100, 4095);
+}
+
+BOOST_AUTO_TEST_CASE( validate_niederreiter_base2_discard )
+{
+ test_niederreiter_base2_discard(niederreiter_base2_02_100, 4095);
+ test_niederreiter_base2_discard(niederreiter_base2_07_100, 4095);
+ test_niederreiter_base2_discard(niederreiter_base2_16_100, 4095);
+}
diff --git a/src/boost/libs/random/test/sobol_validate.cpp b/src/boost/libs/random/test/sobol_validate.cpp
new file mode 100644
index 000000000..941cf58e6
--- /dev/null
+++ b/src/boost/libs/random/test/sobol_validate.cpp
@@ -0,0 +1,380 @@
+// Copyright Justinas Vygintas Daugmaudis, 2010-2018.
+// Use, modification and distribution is subject to the
+// Boost Software License, Version 1.0. (See accompanying
+// file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
+
+#include <boost/random/sobol.hpp>
+
+#include <boost/utility.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include "test_qrng_functions.hpp"
+
+
+//
+// DESCRIPTION:
+// ~~~~~~~~~~~~
+//
+// This file tests the sobol quasi-random number generator.
+// These tests compare our results with values produced by the
+// original sobol.cc program http://web.maths.unsw.edu.au/~fkuo/sobol/,
+// using the new-joe-kuo-6.21201 direction polynomials and direction vectors.
+//
+// Generally, the command line used to generate the datasets was
+// sobol SKIP+N+1 DIMENSION new-joe-kuo-6.21201 | tail -n N
+// Note that we asked to show +1 sample from sobol.cc program, because
+// it outputs trivial zeros as the first sample.
+
+// Spatial dimension: 2
+// N: 99
+// Vectors skipped: 0
+static const double sobol_02_99[99][2] =
+{
+ { 0.5000000002, 0.5000000002 },
+ { 0.7500000003, 0.2500000001 },
+ { 0.2500000001, 0.7500000003 },
+ { 0.3750000002, 0.3750000002 },
+ { 0.8750000004, 0.8750000004 },
+ { 0.6250000003, 0.1250000001 },
+ { 0.1250000001, 0.6250000003 },
+ { 0.1875000001, 0.3125000001 },
+ { 0.6875000003, 0.8125000004 },
+ { 0.9375000004, 0.0625000000 },
+ { 0.4375000002, 0.5625000003 },
+ { 0.3125000001, 0.1875000001 },
+ { 0.8125000004, 0.6875000003 },
+ { 0.5625000003, 0.4375000002 },
+ { 0.0625000000, 0.9375000004 },
+ { 0.0937500000, 0.4687500002 },
+ { 0.5937500003, 0.9687500005 },
+ { 0.8437500004, 0.2187500001 },
+ { 0.3437500002, 0.7187500003 },
+ { 0.4687500002, 0.0937500000 },
+ { 0.9687500005, 0.5937500003 },
+ { 0.7187500003, 0.3437500002 },
+ { 0.2187500001, 0.8437500004 },
+ { 0.1562500001, 0.1562500001 },
+ { 0.6562500003, 0.6562500003 },
+ { 0.9062500004, 0.4062500002 },
+ { 0.4062500002, 0.9062500004 },
+ { 0.2812500001, 0.2812500001 },
+ { 0.7812500004, 0.7812500004 },
+ { 0.5312500002, 0.0312500000 },
+ { 0.0312500000, 0.5312500002 },
+ { 0.0468750000, 0.2656250001 },
+ { 0.5468750003, 0.7656250004 },
+ { 0.7968750004, 0.0156250000 },
+ { 0.2968750001, 0.5156250002 },
+ { 0.4218750002, 0.1406250001 },
+ { 0.9218750004, 0.6406250003 },
+ { 0.6718750003, 0.3906250002 },
+ { 0.1718750001, 0.8906250004 },
+ { 0.2343750001, 0.0781250000 },
+ { 0.7343750003, 0.5781250003 },
+ { 0.9843750005, 0.3281250002 },
+ { 0.4843750002, 0.8281250004 },
+ { 0.3593750002, 0.4531250002 },
+ { 0.8593750004, 0.9531250004 },
+ { 0.6093750003, 0.2031250001 },
+ { 0.1093750001, 0.7031250003 },
+ { 0.0781250000, 0.2343750001 },
+ { 0.5781250003, 0.7343750003 },
+ { 0.8281250004, 0.4843750002 },
+ { 0.3281250002, 0.9843750005 },
+ { 0.4531250002, 0.3593750002 },
+ { 0.9531250004, 0.8593750004 },
+ { 0.7031250003, 0.1093750001 },
+ { 0.2031250001, 0.6093750003 },
+ { 0.1406250001, 0.4218750002 },
+ { 0.6406250003, 0.9218750004 },
+ { 0.8906250004, 0.1718750001 },
+ { 0.3906250002, 0.6718750003 },
+ { 0.2656250001, 0.0468750000 },
+ { 0.7656250004, 0.5468750003 },
+ { 0.5156250002, 0.2968750001 },
+ { 0.0156250000, 0.7968750004 },
+ { 0.0234375000, 0.3984375002 },
+ { 0.5234375002, 0.8984375004 },
+ { 0.7734375004, 0.1484375001 },
+ { 0.2734375001, 0.6484375003 },
+ { 0.3984375002, 0.0234375000 },
+ { 0.8984375004, 0.5234375002 },
+ { 0.6484375003, 0.2734375001 },
+ { 0.1484375001, 0.7734375004 },
+ { 0.2109375001, 0.2109375001 },
+ { 0.7109375003, 0.7109375003 },
+ { 0.9609375004, 0.4609375002 },
+ { 0.4609375002, 0.9609375004 },
+ { 0.3359375002, 0.3359375002 },
+ { 0.8359375004, 0.8359375004 },
+ { 0.5859375003, 0.0859375000 },
+ { 0.0859375000, 0.5859375003 },
+ { 0.1171875001, 0.1171875001 },
+ { 0.6171875003, 0.6171875003 },
+ { 0.8671875004, 0.3671875002 },
+ { 0.3671875002, 0.8671875004 },
+ { 0.4921875002, 0.4921875002 },
+ { 0.9921875005, 0.9921875005 },
+ { 0.7421875003, 0.2421875001 },
+ { 0.2421875001, 0.7421875003 },
+ { 0.1796875001, 0.3046875001 },
+ { 0.6796875003, 0.8046875004 },
+ { 0.9296875004, 0.0546875000 },
+ { 0.4296875002, 0.5546875003 },
+ { 0.3046875001, 0.1796875001 },
+ { 0.8046875004, 0.6796875003 },
+ { 0.5546875003, 0.4296875002 },
+ { 0.0546875000, 0.9296875004 },
+ { 0.0390625000, 0.1328125001 },
+ { 0.5390625003, 0.6328125003 },
+ { 0.7890625004, 0.3828125002 },
+ { 0.2890625001, 0.8828125004 }
+};
+
+// Spatial dimension: 7
+// N: 100
+// Vectors skipped: 127
+static const double sobol_07_100[100][7] =
+{
+ { 0.0117187500, 0.3320312500, 0.2929687500, 0.1914062500, 0.9023437500, 0.6757812500, 0.8632812500 },
+ { 0.5117187500, 0.8320312500, 0.7929687500, 0.6914062500, 0.4023437500, 0.1757812500, 0.3632812500 },
+ { 0.7617187500, 0.0820312500, 0.0429687500, 0.4414062500, 0.1523437500, 0.4257812500, 0.6132812500 },
+ { 0.2617187500, 0.5820312500, 0.5429687500, 0.9414062500, 0.6523437500, 0.9257812500, 0.1132812500 },
+ { 0.3867187500, 0.2070312500, 0.9179687500, 0.8164062500, 0.5273437500, 0.5507812500, 0.7382812500 },
+ { 0.8867187500, 0.7070312500, 0.4179687500, 0.3164062500, 0.0273437500, 0.0507812500, 0.2382812500 },
+ { 0.6367187500, 0.4570312500, 0.6679687500, 0.5664062500, 0.2773437500, 0.3007812500, 0.9882812500 },
+ { 0.1367187500, 0.9570312500, 0.1679687500, 0.0664062500, 0.7773437500, 0.8007812500, 0.4882812500 },
+ { 0.1992187500, 0.0195312500, 0.7304687500, 0.2539062500, 0.4648437500, 0.9882812500, 0.6757812500 },
+ { 0.6992187500, 0.5195312500, 0.2304687500, 0.7539062500, 0.9648437500, 0.4882812500, 0.1757812500 },
+ { 0.9492187500, 0.2695312500, 0.9804687500, 0.0039062500, 0.7148437500, 0.2382812500, 0.9257812500 },
+ { 0.4492187500, 0.7695312500, 0.4804687500, 0.5039062500, 0.2148437500, 0.7382812500, 0.4257812500 },
+ { 0.3242187500, 0.3945312500, 0.1054687500, 0.6289062500, 0.0898437500, 0.8632812500, 0.8007812500 },
+ { 0.8242187500, 0.8945312500, 0.6054687500, 0.1289062500, 0.5898437500, 0.3632812500, 0.3007812500 },
+ { 0.5742187500, 0.1445312500, 0.3554687500, 0.8789062500, 0.8398437500, 0.1132812500, 0.5507812500 },
+ { 0.0742187500, 0.6445312500, 0.8554687500, 0.3789062500, 0.3398437500, 0.6132812500, 0.0507812500 },
+ { 0.1054687500, 0.1757812500, 0.1992187500, 0.5976562500, 0.6835937500, 0.3320312500, 0.3320312500 },
+ { 0.6054687500, 0.6757812500, 0.6992187500, 0.0976562500, 0.1835937500, 0.8320312500, 0.8320312500 },
+ { 0.8554687500, 0.4257812500, 0.4492187500, 0.8476562500, 0.4335937500, 0.5820312500, 0.0820312500 },
+ { 0.3554687500, 0.9257812500, 0.9492187500, 0.3476562500, 0.9335937500, 0.0820312500, 0.5820312500 },
+ { 0.4804687500, 0.3007812500, 0.5742187500, 0.4726562500, 0.8085937500, 0.4570312500, 0.2070312500 },
+ { 0.9804687500, 0.8007812500, 0.0742187500, 0.9726562500, 0.3085937500, 0.9570312500, 0.7070312500 },
+ { 0.7304687500, 0.0507812500, 0.8242187500, 0.2226562500, 0.0585937500, 0.7070312500, 0.4570312500 },
+ { 0.2304687500, 0.5507812500, 0.3242187500, 0.7226562500, 0.5585937500, 0.2070312500, 0.9570312500 },
+ { 0.1679687500, 0.4882812500, 0.7617187500, 0.9101562500, 0.2460937500, 0.0195312500, 0.1445312500 },
+ { 0.6679687500, 0.9882812500, 0.2617187500, 0.4101562500, 0.7460937500, 0.5195312500, 0.6445312500 },
+ { 0.9179687500, 0.2382812500, 0.5117187500, 0.6601562500, 0.9960937500, 0.7695312500, 0.3945312500 },
+ { 0.4179687500, 0.7382812500, 0.0117187500, 0.1601562500, 0.4960937500, 0.2695312500, 0.8945312500 },
+ { 0.2929687500, 0.1132812500, 0.3867187500, 0.0351562500, 0.3710937500, 0.1445312500, 0.2695312500 },
+ { 0.7929687500, 0.6132812500, 0.8867187500, 0.5351562500, 0.8710937500, 0.6445312500, 0.7695312500 },
+ { 0.5429687500, 0.3632812500, 0.1367187500, 0.2851562500, 0.6210937500, 0.8945312500, 0.0195312500 },
+ { 0.0429687500, 0.8632812500, 0.6367187500, 0.7851562500, 0.1210937500, 0.3945312500, 0.5195312500 },
+ { 0.0585937500, 0.0664062500, 0.9960937500, 0.7382812500, 0.7617187500, 0.2539062500, 0.0664062500 },
+ { 0.5585937500, 0.5664062500, 0.4960937500, 0.2382812500, 0.2617187500, 0.7539062500, 0.5664062500 },
+ { 0.8085937500, 0.3164062500, 0.7460937500, 0.9882812500, 0.0117187500, 0.5039062500, 0.3164062500 },
+ { 0.3085937500, 0.8164062500, 0.2460937500, 0.4882812500, 0.5117187500, 0.0039062500, 0.8164062500 },
+ { 0.4335937500, 0.4414062500, 0.3710937500, 0.3632812500, 0.6367187500, 0.3789062500, 0.4414062500 },
+ { 0.9335937500, 0.9414062500, 0.8710937500, 0.8632812500, 0.1367187500, 0.8789062500, 0.9414062500 },
+ { 0.6835937500, 0.1914062500, 0.1210937500, 0.1132812500, 0.3867187500, 0.6289062500, 0.1914062500 },
+ { 0.1835937500, 0.6914062500, 0.6210937500, 0.6132812500, 0.8867187500, 0.1289062500, 0.6914062500 },
+ { 0.2460937500, 0.2539062500, 0.0585937500, 0.8007812500, 0.3242187500, 0.0664062500, 0.3789062500 },
+ { 0.7460937500, 0.7539062500, 0.5585937500, 0.3007812500, 0.8242187500, 0.5664062500, 0.8789062500 },
+ { 0.9960937500, 0.0039062500, 0.3085937500, 0.5507812500, 0.5742187500, 0.8164062500, 0.1289062500 },
+ { 0.4960937500, 0.5039062500, 0.8085937500, 0.0507812500, 0.0742187500, 0.3164062500, 0.6289062500 },
+ { 0.3710937500, 0.1289062500, 0.6835937500, 0.1757812500, 0.1992187500, 0.1914062500, 0.0039062500 },
+ { 0.8710937500, 0.6289062500, 0.1835937500, 0.6757812500, 0.6992187500, 0.6914062500, 0.5039062500 },
+ { 0.6210937500, 0.3789062500, 0.9335937500, 0.4257812500, 0.9492187500, 0.9414062500, 0.2539062500 },
+ { 0.1210937500, 0.8789062500, 0.4335937500, 0.9257812500, 0.4492187500, 0.4414062500, 0.7539062500 },
+ { 0.0898437500, 0.4101562500, 0.5273437500, 0.0820312500, 0.5429687500, 0.7226562500, 0.5976562500 },
+ { 0.5898437500, 0.9101562500, 0.0273437500, 0.5820312500, 0.0429687500, 0.2226562500, 0.0976562500 },
+ { 0.8398437500, 0.1601562500, 0.7773437500, 0.3320312500, 0.2929687500, 0.4726562500, 0.8476562500 },
+ { 0.3398437500, 0.6601562500, 0.2773437500, 0.8320312500, 0.7929687500, 0.9726562500, 0.3476562500 },
+ { 0.4648437500, 0.0351562500, 0.1523437500, 0.9570312500, 0.9179687500, 0.5976562500, 0.9726562500 },
+ { 0.9648437500, 0.5351562500, 0.6523437500, 0.4570312500, 0.4179687500, 0.0976562500, 0.4726562500 },
+ { 0.7148437500, 0.2851562500, 0.4023437500, 0.7070312500, 0.1679687500, 0.3476562500, 0.7226562500 },
+ { 0.2148437500, 0.7851562500, 0.9023437500, 0.2070312500, 0.6679687500, 0.8476562500, 0.2226562500 },
+ { 0.1523437500, 0.2226562500, 0.4648437500, 0.3945312500, 0.1054687500, 0.9101562500, 0.9101562500 },
+ { 0.6523437500, 0.7226562500, 0.9648437500, 0.8945312500, 0.6054687500, 0.4101562500, 0.4101562500 },
+ { 0.9023437500, 0.4726562500, 0.2148437500, 0.1445312500, 0.8554687500, 0.1601562500, 0.6601562500 },
+ { 0.4023437500, 0.9726562500, 0.7148437500, 0.6445312500, 0.3554687500, 0.6601562500, 0.1601562500 },
+ { 0.2773437500, 0.3476562500, 0.8398437500, 0.5195312500, 0.4804687500, 0.7851562500, 0.5351562500 },
+ { 0.7773437500, 0.8476562500, 0.3398437500, 0.0195312500, 0.9804687500, 0.2851562500, 0.0351562500 },
+ { 0.5273437500, 0.0976562500, 0.5898437500, 0.7695312500, 0.7304687500, 0.0351562500, 0.7851562500 },
+ { 0.0273437500, 0.5976562500, 0.0898437500, 0.2695312500, 0.2304687500, 0.5351562500, 0.2851562500 },
+ { 0.0195312500, 0.1992187500, 0.5976562500, 0.9023437500, 0.2539062500, 0.8710937500, 0.4648437500 },
+ { 0.5195312500, 0.6992187500, 0.0976562500, 0.4023437500, 0.7539062500, 0.3710937500, 0.9648437500 },
+ { 0.7695312500, 0.4492187500, 0.8476562500, 0.6523437500, 0.5039062500, 0.1210937500, 0.2148437500 },
+ { 0.2695312500, 0.9492187500, 0.3476562500, 0.1523437500, 0.0039062500, 0.6210937500, 0.7148437500 },
+ { 0.3945312500, 0.3242187500, 0.2226562500, 0.0273437500, 0.1289062500, 0.9960937500, 0.0898437500 },
+ { 0.8945312500, 0.8242187500, 0.7226562500, 0.5273437500, 0.6289062500, 0.4960937500, 0.5898437500 },
+ { 0.6445312500, 0.0742187500, 0.4726562500, 0.2773437500, 0.8789062500, 0.2460937500, 0.3398437500 },
+ { 0.1445312500, 0.5742187500, 0.9726562500, 0.7773437500, 0.3789062500, 0.7460937500, 0.8398437500 },
+ { 0.2070312500, 0.3867187500, 0.4101562500, 0.5898437500, 0.8164062500, 0.5585937500, 0.0273437500 },
+ { 0.7070312500, 0.8867187500, 0.9101562500, 0.0898437500, 0.3164062500, 0.0585937500, 0.5273437500 },
+ { 0.9570312500, 0.1367187500, 0.1601562500, 0.8398437500, 0.0664062500, 0.3085937500, 0.2773437500 },
+ { 0.4570312500, 0.6367187500, 0.6601562500, 0.3398437500, 0.5664062500, 0.8085937500, 0.7773437500 },
+ { 0.3320312500, 0.0117187500, 0.7851562500, 0.4648437500, 0.6914062500, 0.6835937500, 0.4023437500 },
+ { 0.8320312500, 0.5117187500, 0.2851562500, 0.9648437500, 0.1914062500, 0.1835937500, 0.9023437500 },
+ { 0.5820312500, 0.2617187500, 0.5351562500, 0.2148437500, 0.4414062500, 0.4335937500, 0.1523437500 },
+ { 0.0820312500, 0.7617187500, 0.0351562500, 0.7148437500, 0.9414062500, 0.9335937500, 0.6523437500 },
+ { 0.1132812500, 0.2929687500, 0.8789062500, 0.3085937500, 0.0351562500, 0.1523437500, 0.9960937500 },
+ { 0.6132812500, 0.7929687500, 0.3789062500, 0.8085937500, 0.5351562500, 0.6523437500, 0.4960937500 },
+ { 0.8632812500, 0.0429687500, 0.6289062500, 0.0585937500, 0.7851562500, 0.9023437500, 0.7460937500 },
+ { 0.3632812500, 0.5429687500, 0.1289062500, 0.5585937500, 0.2851562500, 0.4023437500, 0.2460937500 },
+ { 0.4882812500, 0.1679687500, 0.2539062500, 0.6835937500, 0.4101562500, 0.0273437500, 0.6210937500 },
+ { 0.9882812500, 0.6679687500, 0.7539062500, 0.1835937500, 0.9101562500, 0.5273437500, 0.1210937500 },
+ { 0.7382812500, 0.4179687500, 0.0039062500, 0.9335937500, 0.6601562500, 0.7773437500, 0.8710937500 },
+ { 0.2382812500, 0.9179687500, 0.5039062500, 0.4335937500, 0.1601562500, 0.2773437500, 0.3710937500 },
+ { 0.1757812500, 0.1054687500, 0.0664062500, 0.2460937500, 0.5976562500, 0.4648437500, 0.5585937500 },
+ { 0.6757812500, 0.6054687500, 0.5664062500, 0.7460937500, 0.0976562500, 0.9648437500, 0.0585937500 },
+ { 0.9257812500, 0.3554687500, 0.3164062500, 0.4960937500, 0.3476562500, 0.7148437500, 0.8085937500 },
+ { 0.4257812500, 0.8554687500, 0.8164062500, 0.9960937500, 0.8476562500, 0.2148437500, 0.3085937500 },
+ { 0.3007812500, 0.4804687500, 0.6914062500, 0.8710937500, 0.9726562500, 0.3398437500, 0.9335937500 },
+ { 0.8007812500, 0.9804687500, 0.1914062500, 0.3710937500, 0.4726562500, 0.8398437500, 0.4335937500 },
+ { 0.5507812500, 0.2304687500, 0.9414062500, 0.6210937500, 0.2226562500, 0.5898437500, 0.6835937500 },
+ { 0.0507812500, 0.7304687500, 0.4414062500, 0.1210937500, 0.7226562500, 0.0898437500, 0.1835937500 },
+ { 0.0351562500, 0.4648437500, 0.1757812500, 0.4179687500, 0.3945312500, 0.1992187500, 0.7304687500 },
+ { 0.5351562500, 0.9648437500, 0.6757812500, 0.9179687500, 0.8945312500, 0.6992187500, 0.2304687500 },
+ { 0.7851562500, 0.2148437500, 0.4257812500, 0.1679687500, 0.6445312500, 0.9492187500, 0.9804687500 },
+ { 0.2851562500, 0.7148437500, 0.9257812500, 0.6679687500, 0.1445312500, 0.4492187500, 0.4804687500 }
+};
+
+// Spatial dimension: 16
+// N: 100
+// Vectors skipped: 127
+static const double sobol_16_100[100][16] =
+{
+ { 0.0117187500, 0.3320312500, 0.2929687500, 0.1914062500, 0.9023437500, 0.6757812500, 0.8632812500, 0.2460937500, 0.1054687500, 0.8164062500, 0.7382812500, 0.7382812500, 0.8164062500, 0.8789062500, 0.0273437500, 0.7617187500 },
+ { 0.5117187500, 0.8320312500, 0.7929687500, 0.6914062500, 0.4023437500, 0.1757812500, 0.3632812500, 0.7460937500, 0.6054687500, 0.3164062500, 0.2382812500, 0.2382812500, 0.3164062500, 0.3789062500, 0.5273437500, 0.2617187500 },
+ { 0.7617187500, 0.0820312500, 0.0429687500, 0.4414062500, 0.1523437500, 0.4257812500, 0.6132812500, 0.9960937500, 0.8554687500, 0.0664062500, 0.4882812500, 0.4882812500, 0.5664062500, 0.6289062500, 0.7773437500, 0.5117187500 },
+ { 0.2617187500, 0.5820312500, 0.5429687500, 0.9414062500, 0.6523437500, 0.9257812500, 0.1132812500, 0.4960937500, 0.3554687500, 0.5664062500, 0.9882812500, 0.9882812500, 0.0664062500, 0.1289062500, 0.2773437500, 0.0117187500 },
+ { 0.3867187500, 0.2070312500, 0.9179687500, 0.8164062500, 0.5273437500, 0.5507812500, 0.7382812500, 0.8710937500, 0.9804687500, 0.4414062500, 0.3632812500, 0.8632812500, 0.6914062500, 0.2539062500, 0.4023437500, 0.1367187500 },
+ { 0.8867187500, 0.7070312500, 0.4179687500, 0.3164062500, 0.0273437500, 0.0507812500, 0.2382812500, 0.3710937500, 0.4804687500, 0.9414062500, 0.8632812500, 0.3632812500, 0.1914062500, 0.7539062500, 0.9023437500, 0.6367187500 },
+ { 0.6367187500, 0.4570312500, 0.6679687500, 0.5664062500, 0.2773437500, 0.3007812500, 0.9882812500, 0.1210937500, 0.2304687500, 0.6914062500, 0.6132812500, 0.1132812500, 0.9414062500, 0.0039062500, 0.6523437500, 0.3867187500 },
+ { 0.1367187500, 0.9570312500, 0.1679687500, 0.0664062500, 0.7773437500, 0.8007812500, 0.4882812500, 0.6210937500, 0.7304687500, 0.1914062500, 0.1132812500, 0.6132812500, 0.4414062500, 0.5039062500, 0.1523437500, 0.8867187500 },
+ { 0.1992187500, 0.0195312500, 0.7304687500, 0.2539062500, 0.4648437500, 0.9882812500, 0.6757812500, 0.8085937500, 0.9179687500, 0.5039062500, 0.0507812500, 0.6757812500, 0.1289062500, 0.0664062500, 0.8398437500, 0.1992187500 },
+ { 0.6992187500, 0.5195312500, 0.2304687500, 0.7539062500, 0.9648437500, 0.4882812500, 0.1757812500, 0.3085937500, 0.4179687500, 0.0039062500, 0.5507812500, 0.1757812500, 0.6289062500, 0.5664062500, 0.3398437500, 0.6992187500 },
+ { 0.9492187500, 0.2695312500, 0.9804687500, 0.0039062500, 0.7148437500, 0.2382812500, 0.9257812500, 0.0585937500, 0.1679687500, 0.2539062500, 0.8007812500, 0.4257812500, 0.3789062500, 0.3164062500, 0.0898437500, 0.4492187500 },
+ { 0.4492187500, 0.7695312500, 0.4804687500, 0.5039062500, 0.2148437500, 0.7382812500, 0.4257812500, 0.5585937500, 0.6679687500, 0.7539062500, 0.3007812500, 0.9257812500, 0.8789062500, 0.8164062500, 0.5898437500, 0.9492187500 },
+ { 0.3242187500, 0.3945312500, 0.1054687500, 0.6289062500, 0.0898437500, 0.8632812500, 0.8007812500, 0.1835937500, 0.0429687500, 0.1289062500, 0.9257812500, 0.8007812500, 0.2539062500, 0.6914062500, 0.7148437500, 0.8242187500 },
+ { 0.8242187500, 0.8945312500, 0.6054687500, 0.1289062500, 0.5898437500, 0.3632812500, 0.3007812500, 0.6835937500, 0.5429687500, 0.6289062500, 0.4257812500, 0.3007812500, 0.7539062500, 0.1914062500, 0.2148437500, 0.3242187500 },
+ { 0.5742187500, 0.1445312500, 0.3554687500, 0.8789062500, 0.8398437500, 0.1132812500, 0.5507812500, 0.9335937500, 0.7929687500, 0.8789062500, 0.1757812500, 0.0507812500, 0.0039062500, 0.9414062500, 0.4648437500, 0.5742187500 },
+ { 0.0742187500, 0.6445312500, 0.8554687500, 0.3789062500, 0.3398437500, 0.6132812500, 0.0507812500, 0.4335937500, 0.2929687500, 0.3789062500, 0.6757812500, 0.5507812500, 0.5039062500, 0.4414062500, 0.9648437500, 0.0742187500 },
+ { 0.1054687500, 0.1757812500, 0.1992187500, 0.5976562500, 0.6835937500, 0.3320312500, 0.3320312500, 0.9023437500, 0.3867187500, 0.9726562500, 0.6445312500, 0.8320312500, 0.4726562500, 0.2851562500, 0.3710937500, 0.7929687500 },
+ { 0.6054687500, 0.6757812500, 0.6992187500, 0.0976562500, 0.1835937500, 0.8320312500, 0.8320312500, 0.4023437500, 0.8867187500, 0.4726562500, 0.1445312500, 0.3320312500, 0.9726562500, 0.7851562500, 0.8710937500, 0.2929687500 },
+ { 0.8554687500, 0.4257812500, 0.4492187500, 0.8476562500, 0.4335937500, 0.5820312500, 0.0820312500, 0.1523437500, 0.6367187500, 0.2226562500, 0.3945312500, 0.0820312500, 0.2226562500, 0.0351562500, 0.6210937500, 0.5429687500 },
+ { 0.3554687500, 0.9257812500, 0.9492187500, 0.3476562500, 0.9335937500, 0.0820312500, 0.5820312500, 0.6523437500, 0.1367187500, 0.7226562500, 0.8945312500, 0.5820312500, 0.7226562500, 0.5351562500, 0.1210937500, 0.0429687500 },
+ { 0.4804687500, 0.3007812500, 0.5742187500, 0.4726562500, 0.8085937500, 0.4570312500, 0.2070312500, 0.0273437500, 0.5117187500, 0.3476562500, 0.2695312500, 0.7070312500, 0.0976562500, 0.9101562500, 0.2460937500, 0.1679687500 },
+ { 0.9804687500, 0.8007812500, 0.0742187500, 0.9726562500, 0.3085937500, 0.9570312500, 0.7070312500, 0.5273437500, 0.0117187500, 0.8476562500, 0.7695312500, 0.2070312500, 0.5976562500, 0.4101562500, 0.7460937500, 0.6679687500 },
+ { 0.7304687500, 0.0507812500, 0.8242187500, 0.2226562500, 0.0585937500, 0.7070312500, 0.4570312500, 0.7773437500, 0.2617187500, 0.5976562500, 0.5195312500, 0.4570312500, 0.3476562500, 0.6601562500, 0.9960937500, 0.4179687500 },
+ { 0.2304687500, 0.5507812500, 0.3242187500, 0.7226562500, 0.5585937500, 0.2070312500, 0.9570312500, 0.2773437500, 0.7617187500, 0.0976562500, 0.0195312500, 0.9570312500, 0.8476562500, 0.1601562500, 0.4960937500, 0.9179687500 },
+ { 0.1679687500, 0.4882812500, 0.7617187500, 0.9101562500, 0.2460937500, 0.0195312500, 0.1445312500, 0.0898437500, 0.5742187500, 0.6601562500, 0.0820312500, 0.7695312500, 0.5351562500, 0.7226562500, 0.5585937500, 0.2304687500 },
+ { 0.6679687500, 0.9882812500, 0.2617187500, 0.4101562500, 0.7460937500, 0.5195312500, 0.6445312500, 0.5898437500, 0.0742187500, 0.1601562500, 0.5820312500, 0.2695312500, 0.0351562500, 0.2226562500, 0.0585937500, 0.7304687500 },
+ { 0.9179687500, 0.2382812500, 0.5117187500, 0.6601562500, 0.9960937500, 0.7695312500, 0.3945312500, 0.8398437500, 0.3242187500, 0.4101562500, 0.8320312500, 0.0195312500, 0.7851562500, 0.9726562500, 0.3085937500, 0.4804687500 },
+ { 0.4179687500, 0.7382812500, 0.0117187500, 0.1601562500, 0.4960937500, 0.2695312500, 0.8945312500, 0.3398437500, 0.8242187500, 0.9101562500, 0.3320312500, 0.5195312500, 0.2851562500, 0.4726562500, 0.8085937500, 0.9804687500 },
+ { 0.2929687500, 0.1132812500, 0.3867187500, 0.0351562500, 0.3710937500, 0.1445312500, 0.2695312500, 0.9648437500, 0.4492187500, 0.0351562500, 0.9570312500, 0.6445312500, 0.9101562500, 0.0976562500, 0.9335937500, 0.8554687500 },
+ { 0.7929687500, 0.6132812500, 0.8867187500, 0.5351562500, 0.8710937500, 0.6445312500, 0.7695312500, 0.4648437500, 0.9492187500, 0.5351562500, 0.4570312500, 0.1445312500, 0.4101562500, 0.5976562500, 0.4335937500, 0.3554687500 },
+ { 0.5429687500, 0.3632812500, 0.1367187500, 0.2851562500, 0.6210937500, 0.8945312500, 0.0195312500, 0.2148437500, 0.6992187500, 0.7851562500, 0.2070312500, 0.3945312500, 0.6601562500, 0.3476562500, 0.1835937500, 0.6054687500 },
+ { 0.0429687500, 0.8632812500, 0.6367187500, 0.7851562500, 0.1210937500, 0.3945312500, 0.5195312500, 0.7148437500, 0.1992187500, 0.2851562500, 0.7070312500, 0.8945312500, 0.1601562500, 0.8476562500, 0.6835937500, 0.1054687500 },
+ { 0.0585937500, 0.0664062500, 0.9960937500, 0.7382812500, 0.7617187500, 0.2539062500, 0.0664062500, 0.5742187500, 0.9023437500, 0.8632812500, 0.8476562500, 0.2851562500, 0.6445312500, 0.1132812500, 0.9804687500, 0.8710937500 },
+ { 0.5585937500, 0.5664062500, 0.4960937500, 0.2382812500, 0.2617187500, 0.7539062500, 0.5664062500, 0.0742187500, 0.4023437500, 0.3632812500, 0.3476562500, 0.7851562500, 0.1445312500, 0.6132812500, 0.4804687500, 0.3710937500 },
+ { 0.8085937500, 0.3164062500, 0.7460937500, 0.9882812500, 0.0117187500, 0.5039062500, 0.3164062500, 0.3242187500, 0.1523437500, 0.1132812500, 0.0976562500, 0.5351562500, 0.8945312500, 0.3632812500, 0.2304687500, 0.6210937500 },
+ { 0.3085937500, 0.8164062500, 0.2460937500, 0.4882812500, 0.5117187500, 0.0039062500, 0.8164062500, 0.8242187500, 0.6523437500, 0.6132812500, 0.5976562500, 0.0351562500, 0.3945312500, 0.8632812500, 0.7304687500, 0.1210937500 },
+ { 0.4335937500, 0.4414062500, 0.3710937500, 0.3632812500, 0.6367187500, 0.3789062500, 0.4414062500, 0.4492187500, 0.0273437500, 0.4882812500, 0.2226562500, 0.1601562500, 0.7695312500, 0.7382812500, 0.6054687500, 0.2460937500 },
+ { 0.9335937500, 0.9414062500, 0.8710937500, 0.8632812500, 0.1367187500, 0.8789062500, 0.9414062500, 0.9492187500, 0.5273437500, 0.9882812500, 0.7226562500, 0.6601562500, 0.2695312500, 0.2382812500, 0.1054687500, 0.7460937500 },
+ { 0.6835937500, 0.1914062500, 0.1210937500, 0.1132812500, 0.3867187500, 0.6289062500, 0.1914062500, 0.6992187500, 0.7773437500, 0.7382812500, 0.9726562500, 0.9101562500, 0.5195312500, 0.9882812500, 0.3554687500, 0.4960937500 },
+ { 0.1835937500, 0.6914062500, 0.6210937500, 0.6132812500, 0.8867187500, 0.1289062500, 0.6914062500, 0.1992187500, 0.2773437500, 0.2382812500, 0.4726562500, 0.4101562500, 0.0195312500, 0.4882812500, 0.8554687500, 0.9960937500 },
+ { 0.2460937500, 0.2539062500, 0.0585937500, 0.8007812500, 0.3242187500, 0.0664062500, 0.3789062500, 0.3867187500, 0.0898437500, 0.5507812500, 0.4101562500, 0.3476562500, 0.3320312500, 0.9257812500, 0.1679687500, 0.1835937500 },
+ { 0.7460937500, 0.7539062500, 0.5585937500, 0.3007812500, 0.8242187500, 0.5664062500, 0.8789062500, 0.8867187500, 0.5898437500, 0.0507812500, 0.9101562500, 0.8476562500, 0.8320312500, 0.4257812500, 0.6679687500, 0.6835937500 },
+ { 0.9960937500, 0.0039062500, 0.3085937500, 0.5507812500, 0.5742187500, 0.8164062500, 0.1289062500, 0.6367187500, 0.8398437500, 0.3007812500, 0.6601562500, 0.5976562500, 0.0820312500, 0.6757812500, 0.9179687500, 0.4335937500 },
+ { 0.4960937500, 0.5039062500, 0.8085937500, 0.0507812500, 0.0742187500, 0.3164062500, 0.6289062500, 0.1367187500, 0.3398437500, 0.8007812500, 0.1601562500, 0.0976562500, 0.5820312500, 0.1757812500, 0.4179687500, 0.9335937500 },
+ { 0.3710937500, 0.1289062500, 0.6835937500, 0.1757812500, 0.1992187500, 0.1914062500, 0.0039062500, 0.5117187500, 0.9648437500, 0.1757812500, 0.5351562500, 0.2226562500, 0.2070312500, 0.3007812500, 0.2929687500, 0.8085937500 },
+ { 0.8710937500, 0.6289062500, 0.1835937500, 0.6757812500, 0.6992187500, 0.6914062500, 0.5039062500, 0.0117187500, 0.4648437500, 0.6757812500, 0.0351562500, 0.7226562500, 0.7070312500, 0.8007812500, 0.7929687500, 0.3085937500 },
+ { 0.6210937500, 0.3789062500, 0.9335937500, 0.4257812500, 0.9492187500, 0.9414062500, 0.2539062500, 0.2617187500, 0.2148437500, 0.9257812500, 0.2851562500, 0.9726562500, 0.4570312500, 0.0507812500, 0.5429687500, 0.5585937500 },
+ { 0.1210937500, 0.8789062500, 0.4335937500, 0.9257812500, 0.4492187500, 0.4414062500, 0.7539062500, 0.7617187500, 0.7148437500, 0.4257812500, 0.7851562500, 0.4726562500, 0.9570312500, 0.5507812500, 0.0429687500, 0.0585937500 },
+ { 0.0898437500, 0.4101562500, 0.5273437500, 0.0820312500, 0.5429687500, 0.7226562500, 0.5976562500, 0.2929687500, 0.6210937500, 0.9570312500, 0.7539062500, 0.1289062500, 0.0507812500, 0.7070312500, 0.6367187500, 0.8398437500 },
+ { 0.5898437500, 0.9101562500, 0.0273437500, 0.5820312500, 0.0429687500, 0.2226562500, 0.0976562500, 0.7929687500, 0.1210937500, 0.4570312500, 0.2539062500, 0.6289062500, 0.5507812500, 0.2070312500, 0.1367187500, 0.3398437500 },
+ { 0.8398437500, 0.1601562500, 0.7773437500, 0.3320312500, 0.2929687500, 0.4726562500, 0.8476562500, 0.5429687500, 0.3710937500, 0.2070312500, 0.0039062500, 0.8789062500, 0.3007812500, 0.9570312500, 0.3867187500, 0.5898437500 },
+ { 0.3398437500, 0.6601562500, 0.2773437500, 0.8320312500, 0.7929687500, 0.9726562500, 0.3476562500, 0.0429687500, 0.8710937500, 0.7070312500, 0.5039062500, 0.3789062500, 0.8007812500, 0.4570312500, 0.8867187500, 0.0898437500 },
+ { 0.4648437500, 0.0351562500, 0.1523437500, 0.9570312500, 0.9179687500, 0.5976562500, 0.9726562500, 0.6679687500, 0.4960937500, 0.3320312500, 0.1289062500, 0.2539062500, 0.4257812500, 0.0820312500, 0.7617187500, 0.2148437500 },
+ { 0.9648437500, 0.5351562500, 0.6523437500, 0.4570312500, 0.4179687500, 0.0976562500, 0.4726562500, 0.1679687500, 0.9960937500, 0.8320312500, 0.6289062500, 0.7539062500, 0.9257812500, 0.5820312500, 0.2617187500, 0.7148437500 },
+ { 0.7148437500, 0.2851562500, 0.4023437500, 0.7070312500, 0.1679687500, 0.3476562500, 0.7226562500, 0.4179687500, 0.7460937500, 0.5820312500, 0.8789062500, 0.5039062500, 0.1757812500, 0.3320312500, 0.0117187500, 0.4648437500 },
+ { 0.2148437500, 0.7851562500, 0.9023437500, 0.2070312500, 0.6679687500, 0.8476562500, 0.2226562500, 0.9179687500, 0.2460937500, 0.0820312500, 0.3789062500, 0.0039062500, 0.6757812500, 0.8320312500, 0.5117187500, 0.9648437500 },
+ { 0.1523437500, 0.2226562500, 0.4648437500, 0.3945312500, 0.1054687500, 0.9101562500, 0.9101562500, 0.7304687500, 0.4335937500, 0.6445312500, 0.4414062500, 0.1914062500, 0.9882812500, 0.2695312500, 0.4492187500, 0.1523437500 },
+ { 0.6523437500, 0.7226562500, 0.9648437500, 0.8945312500, 0.6054687500, 0.4101562500, 0.4101562500, 0.2304687500, 0.9335937500, 0.1445312500, 0.9414062500, 0.6914062500, 0.4882812500, 0.7695312500, 0.9492187500, 0.6523437500 },
+ { 0.9023437500, 0.4726562500, 0.2148437500, 0.1445312500, 0.8554687500, 0.1601562500, 0.6601562500, 0.4804687500, 0.6835937500, 0.3945312500, 0.6914062500, 0.9414062500, 0.7382812500, 0.0195312500, 0.6992187500, 0.4023437500 },
+ { 0.4023437500, 0.9726562500, 0.7148437500, 0.6445312500, 0.3554687500, 0.6601562500, 0.1601562500, 0.9804687500, 0.1835937500, 0.8945312500, 0.1914062500, 0.4414062500, 0.2382812500, 0.5195312500, 0.1992187500, 0.9023437500 },
+ { 0.2773437500, 0.3476562500, 0.8398437500, 0.5195312500, 0.4804687500, 0.7851562500, 0.5351562500, 0.3554687500, 0.5585937500, 0.0195312500, 0.5664062500, 0.3164062500, 0.6132812500, 0.8945312500, 0.0742187500, 0.7773437500 },
+ { 0.7773437500, 0.8476562500, 0.3398437500, 0.0195312500, 0.9804687500, 0.2851562500, 0.0351562500, 0.8554687500, 0.0585937500, 0.5195312500, 0.0664062500, 0.8164062500, 0.1132812500, 0.3945312500, 0.5742187500, 0.2773437500 },
+ { 0.5273437500, 0.0976562500, 0.5898437500, 0.7695312500, 0.7304687500, 0.0351562500, 0.7851562500, 0.6054687500, 0.3085937500, 0.7695312500, 0.3164062500, 0.5664062500, 0.8632812500, 0.6445312500, 0.8242187500, 0.5273437500 },
+ { 0.0273437500, 0.5976562500, 0.0898437500, 0.2695312500, 0.2304687500, 0.5351562500, 0.2851562500, 0.1054687500, 0.8085937500, 0.2695312500, 0.8164062500, 0.0664062500, 0.3632812500, 0.1445312500, 0.3242187500, 0.0273437500 },
+ { 0.0195312500, 0.1992187500, 0.5976562500, 0.9023437500, 0.2539062500, 0.8710937500, 0.4648437500, 0.0351562500, 0.6445312500, 0.8085937500, 0.3085937500, 0.5273437500, 0.7460937500, 0.4023437500, 0.7851562500, 0.2539062500 },
+ { 0.5195312500, 0.6992187500, 0.0976562500, 0.4023437500, 0.7539062500, 0.3710937500, 0.9648437500, 0.5351562500, 0.1445312500, 0.3085937500, 0.8085937500, 0.0273437500, 0.2460937500, 0.9023437500, 0.2851562500, 0.7539062500 },
+ { 0.7695312500, 0.4492187500, 0.8476562500, 0.6523437500, 0.5039062500, 0.1210937500, 0.2148437500, 0.7851562500, 0.3945312500, 0.0585937500, 0.5585937500, 0.2773437500, 0.9960937500, 0.1523437500, 0.0351562500, 0.0039062500 },
+ { 0.2695312500, 0.9492187500, 0.3476562500, 0.1523437500, 0.0039062500, 0.6210937500, 0.7148437500, 0.2851562500, 0.8945312500, 0.5585937500, 0.0585937500, 0.7773437500, 0.4960937500, 0.6523437500, 0.5351562500, 0.5039062500 },
+ { 0.3945312500, 0.3242187500, 0.2226562500, 0.0273437500, 0.1289062500, 0.9960937500, 0.0898437500, 0.9101562500, 0.2695312500, 0.4335937500, 0.6835937500, 0.9023437500, 0.8710937500, 0.7773437500, 0.6601562500, 0.6289062500 },
+ { 0.8945312500, 0.8242187500, 0.7226562500, 0.5273437500, 0.6289062500, 0.4960937500, 0.5898437500, 0.4101562500, 0.7695312500, 0.9335937500, 0.1835937500, 0.4023437500, 0.3710937500, 0.2773437500, 0.1601562500, 0.1289062500 },
+ { 0.6445312500, 0.0742187500, 0.4726562500, 0.2773437500, 0.8789062500, 0.2460937500, 0.3398437500, 0.1601562500, 0.5195312500, 0.6835937500, 0.4335937500, 0.1523437500, 0.6210937500, 0.5273437500, 0.4101562500, 0.8789062500 },
+ { 0.1445312500, 0.5742187500, 0.9726562500, 0.7773437500, 0.3789062500, 0.7460937500, 0.8398437500, 0.6601562500, 0.0195312500, 0.1835937500, 0.9335937500, 0.6523437500, 0.1210937500, 0.0273437500, 0.9101562500, 0.3789062500 },
+ { 0.2070312500, 0.3867187500, 0.4101562500, 0.5898437500, 0.8164062500, 0.5585937500, 0.0273437500, 0.9726562500, 0.3320312500, 0.6210937500, 0.9960937500, 0.5898437500, 0.3085937500, 0.5898437500, 0.0976562500, 0.6914062500 },
+ { 0.7070312500, 0.8867187500, 0.9101562500, 0.0898437500, 0.3164062500, 0.0585937500, 0.5273437500, 0.4726562500, 0.8320312500, 0.1210937500, 0.4960937500, 0.0898437500, 0.8085937500, 0.0898437500, 0.5976562500, 0.1914062500 },
+ { 0.9570312500, 0.1367187500, 0.1601562500, 0.8398437500, 0.0664062500, 0.3085937500, 0.2773437500, 0.2226562500, 0.5820312500, 0.3710937500, 0.2460937500, 0.3398437500, 0.0585937500, 0.8398437500, 0.8476562500, 0.9414062500 },
+ { 0.4570312500, 0.6367187500, 0.6601562500, 0.3398437500, 0.5664062500, 0.8085937500, 0.7773437500, 0.7226562500, 0.0820312500, 0.8710937500, 0.7460937500, 0.8398437500, 0.5585937500, 0.3398437500, 0.3476562500, 0.4414062500 },
+ { 0.3320312500, 0.0117187500, 0.7851562500, 0.4648437500, 0.6914062500, 0.6835937500, 0.4023437500, 0.0976562500, 0.7070312500, 0.2460937500, 0.1210937500, 0.9648437500, 0.1835937500, 0.2148437500, 0.4726562500, 0.3164062500 },
+ { 0.8320312500, 0.5117187500, 0.2851562500, 0.9648437500, 0.1914062500, 0.1835937500, 0.9023437500, 0.5976562500, 0.2070312500, 0.7460937500, 0.6210937500, 0.4648437500, 0.6835937500, 0.7148437500, 0.9726562500, 0.8164062500 },
+ { 0.5820312500, 0.2617187500, 0.5351562500, 0.2148437500, 0.4414062500, 0.4335937500, 0.1523437500, 0.8476562500, 0.4570312500, 0.9960937500, 0.8710937500, 0.2148437500, 0.4335937500, 0.4648437500, 0.7226562500, 0.0664062500 },
+ { 0.0820312500, 0.7617187500, 0.0351562500, 0.7148437500, 0.9414062500, 0.9335937500, 0.6523437500, 0.3476562500, 0.9570312500, 0.4960937500, 0.3710937500, 0.7148437500, 0.9335937500, 0.9648437500, 0.2226562500, 0.5664062500 },
+ { 0.1132812500, 0.2929687500, 0.8789062500, 0.3085937500, 0.0351562500, 0.1523437500, 0.9960937500, 0.8164062500, 0.8632812500, 0.9023437500, 0.3398437500, 0.9335937500, 0.0898437500, 0.8085937500, 0.5664062500, 0.2851562500 },
+ { 0.6132812500, 0.7929687500, 0.3789062500, 0.8085937500, 0.5351562500, 0.6523437500, 0.4960937500, 0.3164062500, 0.3632812500, 0.4023437500, 0.8398437500, 0.4335937500, 0.5898437500, 0.3085937500, 0.0664062500, 0.7851562500 },
+ { 0.8632812500, 0.0429687500, 0.6289062500, 0.0585937500, 0.7851562500, 0.9023437500, 0.7460937500, 0.0664062500, 0.1132812500, 0.1523437500, 0.5898437500, 0.1835937500, 0.3398437500, 0.5585937500, 0.3164062500, 0.0351562500 },
+ { 0.3632812500, 0.5429687500, 0.1289062500, 0.5585937500, 0.2851562500, 0.4023437500, 0.2460937500, 0.5664062500, 0.6132812500, 0.6523437500, 0.0898437500, 0.6835937500, 0.8398437500, 0.0585937500, 0.8164062500, 0.5351562500 },
+ { 0.4882812500, 0.1679687500, 0.2539062500, 0.6835937500, 0.4101562500, 0.0273437500, 0.6210937500, 0.1914062500, 0.2382812500, 0.2773437500, 0.7148437500, 0.5585937500, 0.4648437500, 0.4335937500, 0.9414062500, 0.6601562500 },
+ { 0.9882812500, 0.6679687500, 0.7539062500, 0.1835937500, 0.9101562500, 0.5273437500, 0.1210937500, 0.6914062500, 0.7382812500, 0.7773437500, 0.2148437500, 0.0585937500, 0.9648437500, 0.9335937500, 0.4414062500, 0.1601562500 },
+ { 0.7382812500, 0.4179687500, 0.0039062500, 0.9335937500, 0.6601562500, 0.7773437500, 0.8710937500, 0.9414062500, 0.9882812500, 0.5273437500, 0.4648437500, 0.3085937500, 0.2148437500, 0.1835937500, 0.1914062500, 0.9101562500 },
+ { 0.2382812500, 0.9179687500, 0.5039062500, 0.4335937500, 0.1601562500, 0.2773437500, 0.3710937500, 0.4414062500, 0.4882812500, 0.0273437500, 0.9648437500, 0.8085937500, 0.7148437500, 0.6835937500, 0.6914062500, 0.4101562500 },
+ { 0.1757812500, 0.1054687500, 0.0664062500, 0.2460937500, 0.5976562500, 0.4648437500, 0.5585937500, 0.1289062500, 0.1757812500, 0.7148437500, 0.9023437500, 0.9960937500, 0.9023437500, 0.2460937500, 0.2539062500, 0.7226562500 },
+ { 0.6757812500, 0.6054687500, 0.5664062500, 0.7460937500, 0.0976562500, 0.9648437500, 0.0585937500, 0.6289062500, 0.6757812500, 0.2148437500, 0.4023437500, 0.4960937500, 0.4023437500, 0.7460937500, 0.7539062500, 0.2226562500 },
+ { 0.9257812500, 0.3554687500, 0.3164062500, 0.4960937500, 0.3476562500, 0.7148437500, 0.8085937500, 0.8789062500, 0.9257812500, 0.4648437500, 0.1523437500, 0.2460937500, 0.6523437500, 0.4960937500, 0.5039062500, 0.9726562500 },
+ { 0.4257812500, 0.8554687500, 0.8164062500, 0.9960937500, 0.8476562500, 0.2148437500, 0.3085937500, 0.3789062500, 0.4257812500, 0.9648437500, 0.6523437500, 0.7460937500, 0.1523437500, 0.9960937500, 0.0039062500, 0.4726562500 },
+ { 0.3007812500, 0.4804687500, 0.6914062500, 0.8710937500, 0.9726562500, 0.3398437500, 0.9335937500, 0.7539062500, 0.8007812500, 0.0898437500, 0.0273437500, 0.6210937500, 0.5273437500, 0.6210937500, 0.1289062500, 0.3476562500 },
+ { 0.8007812500, 0.9804687500, 0.1914062500, 0.3710937500, 0.4726562500, 0.8398437500, 0.4335937500, 0.2539062500, 0.3007812500, 0.5898437500, 0.5273437500, 0.1210937500, 0.0273437500, 0.1210937500, 0.6289062500, 0.8476562500 },
+ { 0.5507812500, 0.2304687500, 0.9414062500, 0.6210937500, 0.2226562500, 0.5898437500, 0.6835937500, 0.0039062500, 0.0507812500, 0.8398437500, 0.7773437500, 0.3710937500, 0.7773437500, 0.8710937500, 0.8789062500, 0.0976562500 },
+ { 0.0507812500, 0.7304687500, 0.4414062500, 0.1210937500, 0.7226562500, 0.0898437500, 0.1835937500, 0.5039062500, 0.5507812500, 0.3398437500, 0.2773437500, 0.8710937500, 0.2773437500, 0.3710937500, 0.3789062500, 0.5976562500 },
+ { 0.0351562500, 0.4648437500, 0.1757812500, 0.4179687500, 0.3945312500, 0.1992187500, 0.7304687500, 0.6445312500, 0.3476562500, 0.7617187500, 0.1679687500, 0.4492187500, 0.7929687500, 0.6054687500, 0.2070312500, 0.3632812500 },
+ { 0.5351562500, 0.9648437500, 0.6757812500, 0.9179687500, 0.8945312500, 0.6992187500, 0.2304687500, 0.1445312500, 0.8476562500, 0.2617187500, 0.6679687500, 0.9492187500, 0.2929687500, 0.1054687500, 0.7070312500, 0.8632812500 },
+ { 0.7851562500, 0.2148437500, 0.4257812500, 0.1679687500, 0.6445312500, 0.9492187500, 0.9804687500, 0.3945312500, 0.5976562500, 0.0117187500, 0.9179687500, 0.6992187500, 0.5429687500, 0.8554687500, 0.9570312500, 0.1132812500 },
+ { 0.2851562500, 0.7148437500, 0.9257812500, 0.6679687500, 0.1445312500, 0.4492187500, 0.4804687500, 0.8945312500, 0.0976562500, 0.5117187500, 0.4179687500, 0.1992187500, 0.0429687500, 0.3554687500, 0.4570312500, 0.6132812500 }
+};
+
+
+QRNG_VALIDATION_TEST_FUNCTIONS(sobol)
+QRNG_VALIDATION_TEST_DISCARD(sobol)
+
+BOOST_AUTO_TEST_CASE( check_generator_limits )
+{
+ test_sobol_max_seed();
+ test_sobol_max_discard();
+ test_sobol_max_dimension(BOOST_RANDOM_SOBOL_MAX_DIMENSION);
+}
+
+BOOST_AUTO_TEST_CASE( validate_sobol )
+{
+ test_sobol_values(sobol_02_99, 0);
+ test_sobol_values(sobol_07_100, 127);
+ test_sobol_values(sobol_16_100, 127);
+}
+
+BOOST_AUTO_TEST_CASE( validate_sobol_seed )
+{
+ test_sobol_seed(sobol_02_99, 0);
+ test_sobol_seed(sobol_07_100, 127);
+ test_sobol_seed(sobol_16_100, 127);
+}
+
+BOOST_AUTO_TEST_CASE( validate_sobol_discard )
+{
+ test_sobol_discard(sobol_02_99, 0);
+ test_sobol_discard(sobol_07_100, 127);
+ test_sobol_discard(sobol_16_100, 127);
+}
diff --git a/src/boost/libs/random/test/statistic_tests.cpp b/src/boost/libs/random/test/statistic_tests.cpp
new file mode 100644
index 000000000..717985b26
--- /dev/null
+++ b/src/boost/libs/random/test/statistic_tests.cpp
@@ -0,0 +1,503 @@
+/* statistic_tests.cpp file
+ *
+ * Copyright Jens Maurer 2000, 2002
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ * Revision history
+ */
+
+#include <iostream>
+#include <iomanip>
+#include <string>
+#include <functional>
+#include <vector>
+#include <set>
+#include <algorithm>
+
+#include <boost/cstdint.hpp>
+#include <boost/random.hpp>
+
+#include <boost/math/special_functions/gamma.hpp>
+
+#include <boost/math/distributions/uniform.hpp>
+#include <boost/math/distributions/chi_squared.hpp>
+#include <boost/math/distributions/normal.hpp>
+#include <boost/math/distributions/triangular.hpp>
+#include <boost/math/distributions/cauchy.hpp>
+#include <boost/math/distributions/gamma.hpp>
+#include <boost/math/distributions/exponential.hpp>
+#include <boost/math/distributions/lognormal.hpp>
+
+#include "statistic_tests.hpp"
+#include "integrate.hpp"
+
+class test_environment;
+
+class test_base
+{
+protected:
+ explicit test_base(test_environment & env) : environment(env) { }
+ void check_(double val) const;
+private:
+ test_environment & environment;
+};
+
+class equidistribution_test : test_base
+{
+public:
+ equidistribution_test(test_environment & env, unsigned int classes,
+ unsigned int high_classes)
+ : test_base(env), classes(classes),
+ test_distrib_chi_square(boost::math::chi_squared(classes-1), high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "equidistribution: " << std::flush;
+ equidistribution_experiment equi(classes);
+ variate_generator<RNG&, uniform_smallint<> > uint_linear(rng, uniform_smallint<>(0, classes-1));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(equi, uint_linear, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(equi, uint_linear, n1), 2*n2));
+
+ std::cout << " 2D: " << std::flush;
+ equidistribution_2d_experiment equi_2d(classes);
+ unsigned int root = static_cast<unsigned int>(std::sqrt(double(classes)));
+ assert(root * root == classes);
+ variate_generator<RNG&, uniform_smallint<> > uint_square(rng, uniform_smallint<>(0, root-1));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(equi_2d, uint_square, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(equi_2d, uint_square, n1), 2*n2));
+ std::cout << std::endl;
+ }
+private:
+ unsigned int classes;
+ distribution_experiment test_distrib_chi_square;
+};
+
+class ks_distribution_test : test_base
+{
+public:
+ ks_distribution_test(test_environment & env, unsigned int classes)
+ : test_base(env),
+ test_distrib_chi_square(kolmogorov_smirnov_probability(5000),
+ classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ boost::math::uniform ud(static_cast<double>((rng.min)()), static_cast<double>((rng.max)()));
+ run(rng, ud, n1, n2);
+ }
+ template<class RNG, class Dist>
+ void run(RNG & rng, const Dist& dist, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "KS: " << std::flush;
+ kolmogorov_experiment ks(n1);
+ check_(run_experiment(test_distrib_chi_square,
+ ks_experiment_generator(ks, rng, dist), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ ks_experiment_generator(ks, rng, dist), 2*n2));
+ std::cout << std::endl;
+ }
+private:
+ distribution_experiment test_distrib_chi_square;
+};
+
+class runs_test : test_base
+{
+public:
+ runs_test(test_environment & env, unsigned int classes,
+ unsigned int high_classes)
+ : test_base(env), classes(classes),
+ test_distrib_chi_square(boost::math::chi_squared(classes-1), high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "runs: up: " << std::flush;
+ runs_experiment<true> r_up(classes);
+
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(r_up, rng, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(r_up, rng, n1), 2*n2));
+
+ std::cout << " down: " << std::flush;
+ runs_experiment<false> r_down(classes);
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(r_down, rng, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(r_down, rng, n1), 2*n2));
+
+ std::cout << std::endl;
+ }
+private:
+ unsigned int classes;
+ distribution_experiment test_distrib_chi_square;
+};
+
+class gap_test : test_base
+{
+public:
+ gap_test(test_environment & env, unsigned int classes,
+ unsigned int high_classes)
+ : test_base(env), classes(classes),
+ test_distrib_chi_square(boost::math::chi_squared(classes-1), high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ boost::math::uniform ud(
+ static_cast<double>((rng.min)()),
+ static_cast<double>((rng.max)()) +
+ (std::numeric_limits<typename RNG::result_type>::is_integer? 0.0 : 1.0));
+ run(rng, ud, n1, n2);
+ }
+
+ template<class RNG, class Dist>
+ void run(RNG & rng, const Dist& dist, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "gaps: " << std::flush;
+ gap_experiment gap(classes, dist, 0.2, 0.8);
+
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(gap, rng, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(gap, rng, n1), 2*n2));
+
+ std::cout << std::endl;
+ }
+private:
+ unsigned int classes;
+ distribution_experiment test_distrib_chi_square;
+};
+
+class poker_test : test_base
+{
+public:
+ poker_test(test_environment & env, unsigned int classes,
+ unsigned int high_classes)
+ : test_base(env), classes(classes),
+ test_distrib_chi_square(boost::math::chi_squared(classes-1), high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "poker: " << std::flush;
+ poker_experiment poker(8, classes);
+ variate_generator<RNG&, uniform_smallint<> > usmall(rng, uniform_smallint<>(0, 7));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(poker, usmall, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(poker, usmall, n1), 2*n2));
+ std::cout << std::endl;
+ }
+private:
+ unsigned int classes;
+ distribution_experiment test_distrib_chi_square;
+};
+
+class coupon_collector_test : test_base
+{
+public:
+ coupon_collector_test(test_environment & env, unsigned int classes,
+ unsigned int high_classes)
+ : test_base(env), classes(classes),
+ test_distrib_chi_square(boost::math::chi_squared(classes-1), high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "coupon collector: " << std::flush;
+ coupon_collector_experiment coupon(5, classes);
+
+ variate_generator<RNG&, uniform_smallint<> > usmall(rng, uniform_smallint<>(0, 4));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(coupon, usmall, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(coupon, usmall, n1), 2*n2));
+ std::cout << std::endl;
+ }
+private:
+ unsigned int classes;
+ distribution_experiment test_distrib_chi_square;
+};
+
+class permutation_test : test_base
+{
+public:
+ permutation_test(test_environment & env, unsigned int classes,
+ unsigned int high_classes)
+ : test_base(env), classes(classes),
+ test_distrib_chi_square(boost::math::chi_squared(fac<int>(classes)-1),
+ high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "permutation: " << std::flush;
+ permutation_experiment perm(classes);
+
+ // generator_reference_t<RNG> gen_ref(rng);
+ RNG& gen_ref(rng);
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(perm, gen_ref, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(perm, gen_ref, n1), 2*n2));
+ std::cout << std::endl;
+ }
+private:
+ unsigned int classes;
+ distribution_experiment test_distrib_chi_square;
+};
+
+class maximum_test : test_base
+{
+public:
+ maximum_test(test_environment & env, unsigned int high_classes)
+ : test_base(env),
+ test_distrib_chi_square(kolmogorov_smirnov_probability(1000),
+ high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "maximum-of-t: " << std::flush;
+ maximum_experiment<RNG> mx(rng, n1, 5);
+ check_(run_experiment(test_distrib_chi_square, mx, n2));
+ check_(run_experiment(test_distrib_chi_square, mx, 2*n2));
+ std::cout << std::endl;
+ }
+private:
+ distribution_experiment test_distrib_chi_square;
+};
+
+class birthday_test : test_base
+{
+public:
+ birthday_test(test_environment & env, unsigned int high_classes)
+ : test_base(env),
+ test_distrib_chi_square(boost::math::chi_squared(4-1), high_classes)
+ { }
+
+ template<class RNG>
+ void run(RNG & rng, int n1, int n2)
+ {
+ using namespace boost;
+ std::cout << "birthday spacing: " << std::flush;
+ boost::variate_generator<RNG&, boost::uniform_int<> > uni(rng, boost::uniform_int<>(0, (1<<25)-1));
+ birthday_spacing_experiment bsp(4, 512, (1<<25));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(bsp, uni, n1), n2));
+ check_(run_experiment(test_distrib_chi_square,
+ experiment_generator(bsp, uni, n1), 2*n2));
+ std::cout << std::endl;
+ }
+private:
+ distribution_experiment test_distrib_chi_square;
+};
+
+#ifdef BOOST_MSVC
+#pragma warning(disable:4355)
+#endif
+
+class test_environment
+{
+public:
+ static const int classes = 20;
+ explicit test_environment(double confid)
+ : confidence(confid),
+ confidence_chi_square_quantil(quantile(boost::math::chi_squared(classes-1), confidence)),
+ test_distrib_chi_square6(boost::math::chi_squared(7-1), classes),
+ ksdist_test(*this, classes),
+ equi_test(*this, 100, classes),
+ rns_test(*this, 7, classes),
+ gp_test(*this, 7, classes),
+ pk_test(*this, 5, classes),
+ cpn_test(*this, 15, classes),
+ perm_test(*this, 5, classes),
+ max_test(*this, classes),
+ bday_test(*this, classes)
+ {
+ std::cout << "Confidence level: " << confid
+ << "; 1-alpha = " << (1-confid)
+ << "; chi_square(" << (classes-1)
+ << ", " << confidence_chi_square_quantil
+ << ") = "
+ << cdf(boost::math::chi_squared(classes-1), confidence_chi_square_quantil)
+ << std::endl;
+ }
+
+ bool check_confidence(double val, double chi_square_conf) const
+ {
+ std::cout << val;
+ bool result = (val <= chi_square_conf);
+ if(!result) {
+ std::cout << "* [";
+ double prob = (val > 10*chi_square_conf ? 1 :
+ cdf(boost::math::chi_squared(classes-1), val));
+ std::cout << (1-prob) << "]";
+ }
+ std::cout << " " << std::flush;
+ return result;
+ }
+
+ bool check_(double chi_square_value) const
+ {
+ return check_confidence(chi_square_value, confidence_chi_square_quantil);
+ }
+
+ template<class RNG>
+ void run_test(const std::string & name)
+ {
+ using namespace boost;
+
+ std::cout << "Running tests on " << name << std::endl;
+
+ RNG rng(1234567);
+
+ ksdist_test.run(rng, 5000, 250);
+ equi_test.run(rng, 5000, 250);
+ rns_test.run(rng, 100000, 250);
+ gp_test.run(rng, 10000, 250);
+ pk_test.run(rng, 5000, 250);
+ cpn_test.run(rng, 500, 250);
+ perm_test.run(rng, 1200, 250);
+ max_test.run(rng, 1000, 250);
+ bday_test.run(rng, 1000, 150);
+
+ std::cout << std::endl;
+ }
+
+ template<class RNG, class Dist, class ExpectedDist>
+ void run_test(const std::string & name, const Dist & dist, const ExpectedDist & expected_dist)
+ {
+ using namespace boost;
+
+ std::cout << "Running tests on " << name << std::endl;
+
+ RNG rng;
+ variate_generator<RNG&, Dist> vgen(rng, dist);
+
+ ksdist_test.run(vgen, expected_dist, 5000, 250);
+ rns_test.run(vgen, 100000, 250);
+ gp_test.run(vgen, expected_dist, 10000, 250);
+ perm_test.run(vgen, 1200, 250);
+
+ std::cout << std::endl;
+ }
+
+private:
+ double confidence;
+ double confidence_chi_square_quantil;
+ distribution_experiment test_distrib_chi_square6;
+ ks_distribution_test ksdist_test;
+ equidistribution_test equi_test;
+ runs_test rns_test;
+ gap_test gp_test;
+ poker_test pk_test;
+ coupon_collector_test cpn_test;
+ permutation_test perm_test;
+ maximum_test max_test;
+ birthday_test bday_test;
+};
+
+void test_base::check_(double val) const
+{
+ environment.check_(val);
+}
+
+class program_args
+{
+public:
+ program_args(int argc, char** argv)
+ {
+ if(argc > 0) {
+ names.insert(argv + 1, argv + argc);
+ }
+ }
+ bool check_(const std::string & test_name) const
+ {
+ return(names.empty() || names.find(test_name) != names.end());
+ }
+private:
+ std::set<std::string> names;
+};
+
+int main(int argc, char* argv[])
+{
+ program_args args(argc, argv);
+ test_environment env(0.99);
+
+#define TEST(name) \
+ if(args.check_(#name)) \
+ env.run_test<boost::name>(#name)
+
+ TEST(minstd_rand0);
+ TEST(minstd_rand);
+ TEST(rand48);
+ TEST(ecuyer1988);
+ TEST(kreutzer1986);
+ TEST(taus88);
+ TEST(hellekalek1995);
+ TEST(mt11213b);
+ TEST(mt19937);
+ TEST(lagged_fibonacci607);
+ TEST(lagged_fibonacci1279);
+ TEST(lagged_fibonacci2281);
+ TEST(lagged_fibonacci3217);
+ TEST(lagged_fibonacci4423);
+ TEST(lagged_fibonacci9689);
+ TEST(lagged_fibonacci19937);
+ TEST(lagged_fibonacci23209);
+ TEST(lagged_fibonacci44497);
+ TEST(ranlux3);
+ TEST(ranlux4);
+
+#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
+ TEST(ranlux64_3);
+ TEST(ranlux64_4);
+#endif
+
+ TEST(ranlux3_01);
+ TEST(ranlux4_01);
+ TEST(ranlux64_3_01);
+ TEST(ranlux64_4_01);
+
+ if(args.check_("normal"))
+ env.run_test<boost::mt19937>("normal", boost::normal_distribution<>(), boost::math::normal());
+ if(args.check_("triangle"))
+ env.run_test<boost::mt19937>("triangle", boost::triangle_distribution<>(0, 1, 3), boost::math::triangular(0, 1, 3));
+ if(args.check_("cauchy"))
+ env.run_test<boost::mt19937>("cauchy", boost::cauchy_distribution<>(), boost::math::cauchy());
+ if(args.check_("gamma"))
+ env.run_test<boost::mt19937>("gamma", boost::gamma_distribution<>(1), boost::math::gamma_distribution<>(1));
+ if(args.check_("exponential"))
+ env.run_test<boost::mt19937>("exponential", boost::exponential_distribution<>(), boost::math::exponential());
+ if(args.check_("lognormal"))
+ env.run_test<boost::mt19937>("lognormal", boost::lognormal_distribution<>(1, 1),
+ boost::math::lognormal(std::log(1.0/std::sqrt(2.0)), std::sqrt(std::log(2.0))));
+}
diff --git a/src/boost/libs/random/test/statistic_tests.hpp b/src/boost/libs/random/test/statistic_tests.hpp
new file mode 100644
index 000000000..c1feb5559
--- /dev/null
+++ b/src/boost/libs/random/test/statistic_tests.hpp
@@ -0,0 +1,709 @@
+/* statistic_tests.hpp header file
+ *
+ * Copyright Jens Maurer 2000
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#ifndef STATISTIC_TESTS_HPP
+#define STATISTIC_TESTS_HPP
+
+#include <stdexcept>
+#include <iterator>
+#include <vector>
+#include <boost/limits.hpp>
+#include <algorithm>
+#include <cmath>
+
+#include <boost/config.hpp>
+#include <boost/bind.hpp>
+#include <boost/random/uniform_01.hpp>
+#include <boost/random/variate_generator.hpp>
+
+#include "integrate.hpp"
+
+#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
+namespace std
+{
+ inline double pow(double a, double b) { return ::pow(a,b); }
+ inline double ceil(double x) { return ::ceil(x); }
+} // namespace std
+#endif
+
+
+template<class T>
+inline T fac(int k)
+{
+ T result = 1;
+ for(T i = 2; i <= k; ++i)
+ result *= i;
+ return result;
+}
+
+template<class T>
+T binomial(int n, int k)
+{
+ if(k < n/2)
+ k = n-k;
+ T result = 1;
+ for(int i = k+1; i<= n; ++i)
+ result *= i;
+ return result / fac<T>(n-k);
+}
+
+template<class T>
+T stirling2(int n, int m)
+{
+ T sum = 0;
+ for(int k = 0; k <= m; ++k)
+ sum += binomial<T>(m, k) * std::pow(double(k), n) *
+ ( (m-k)%2 == 0 ? 1 : -1);
+ return sum / fac<T>(m);
+}
+
+/*
+ * Experiments which create an empirical distribution in classes,
+ * suitable for the chi-square test.
+ */
+// std::floor(gen() * classes)
+
+class experiment_base
+{
+public:
+ experiment_base(int cls) : _classes(cls) { }
+ unsigned int classes() const { return _classes; }
+protected:
+ unsigned int _classes;
+};
+
+class equidistribution_experiment : public experiment_base
+{
+public:
+ explicit equidistribution_experiment(unsigned int classes)
+ : experiment_base(classes) { }
+
+ template<class NumberGenerator, class Counter>
+ void run(NumberGenerator & f, Counter & count, int n) const
+ {
+ assert((f.min)() == 0 &&
+ static_cast<unsigned int>((f.max)()) == classes()-1);
+ for(int i = 0; i < n; ++i)
+ count(f());
+ }
+ double probability(int /*i*/) const { return 1.0/classes(); }
+};
+
+// two-dimensional equidistribution experiment
+class equidistribution_2d_experiment : public equidistribution_experiment
+{
+public:
+ explicit equidistribution_2d_experiment(unsigned int classes)
+ : equidistribution_experiment(classes) { }
+
+ template<class NumberGenerator, class Counter>
+ void run(NumberGenerator & f, Counter & count, int n) const
+ {
+ unsigned int range = (f.max)()+1;
+ assert((f.min)() == 0 && range*range == classes());
+ for(int i = 0; i < n; ++i) {
+ int y1 = f();
+ int y2 = f();
+ count(y1 + range * y2);
+ }
+ }
+};
+
+// distribution experiment: assume a probability density and
+// count events so that an equidistribution results.
+class distribution_experiment : public equidistribution_experiment
+{
+public:
+ template<class Distribution>
+ distribution_experiment(Distribution dist , unsigned int classes)
+ : equidistribution_experiment(classes), limit(classes)
+ {
+ for(unsigned int i = 0; i < classes-1; ++i)
+ limit[i] = quantile(dist, (i+1)*0.05);
+ limit[classes-1] = std::numeric_limits<double>::infinity();
+ if(limit[classes-1] < (std::numeric_limits<double>::max)())
+ limit[classes-1] = (std::numeric_limits<double>::max)();
+#if 0
+ std::cout << __PRETTY_FUNCTION__ << ": ";
+ for(unsigned int i = 0; i < classes; ++i)
+ std::cout << limit[i] << " ";
+ std::cout << std::endl;
+#endif
+ }
+
+ template<class NumberGenerator, class Counter>
+ void run(NumberGenerator & f, Counter & count, int n) const
+ {
+ for(int i = 0; i < n; ++i) {
+ limits_type::const_iterator it =
+ std::lower_bound(limit.begin(), limit.end(), f());
+ count(it-limit.begin());
+ }
+ }
+private:
+ typedef std::vector<double> limits_type;
+ limits_type limit;
+};
+
+template<bool up, bool is_float>
+struct runs_direction_helper
+{
+ template<class T>
+ static T init(T)
+ {
+ return (std::numeric_limits<T>::max)();
+ }
+};
+
+template<>
+struct runs_direction_helper<true, true>
+{
+ template<class T>
+ static T init(T)
+ {
+ return -(std::numeric_limits<T>::max)();
+ }
+};
+
+template<>
+struct runs_direction_helper<true, false>
+{
+ template<class T>
+ static T init(T)
+ {
+ return (std::numeric_limits<T>::min)();
+ }
+};
+
+// runs-up/runs-down experiment
+template<bool up>
+class runs_experiment : public experiment_base
+{
+public:
+ explicit runs_experiment(unsigned int classes) : experiment_base(classes) { }
+
+ template<class NumberGenerator, class Counter>
+ void run(NumberGenerator & f, Counter & count, int n) const
+ {
+ typedef typename NumberGenerator::result_type result_type;
+ result_type init =
+ runs_direction_helper<
+ up,
+ !std::numeric_limits<result_type>::is_integer
+ >::init(result_type());
+ result_type previous = init;
+ unsigned int length = 0;
+ for(int i = 0; i < n; ++i) {
+ result_type val = f();
+ if(up ? previous <= val : previous >= val) {
+ previous = val;
+ ++length;
+ } else {
+ count((std::min)(length, classes())-1);
+ length = 0;
+ previous = init;
+ // don't use this value, so that runs are independent
+ }
+ }
+ }
+ double probability(unsigned int r) const
+ {
+ if(r == classes()-1)
+ return 1.0/fac<double>(classes());
+ else
+ return static_cast<double>(r+1)/fac<double>(r+2);
+ }
+};
+
+// gap length experiment
+class gap_experiment : public experiment_base
+{
+public:
+ template<class Dist>
+ gap_experiment(unsigned int classes, const Dist & dist, double alpha, double beta)
+ : experiment_base(classes), alpha(alpha), beta(beta), low(quantile(dist, alpha)), high(quantile(dist, beta)) {}
+
+ template<class NumberGenerator, class Counter>
+ void run(NumberGenerator & f, Counter & count, int n) const
+ {
+ typedef typename NumberGenerator::result_type result_type;
+ unsigned int length = 0;
+ for(int i = 0; i < n; ) {
+ result_type value = f();
+ if(value < low || value > high)
+ ++length;
+ else {
+ count((std::min)(length, classes()-1));
+ length = 0;
+ ++i;
+ }
+ }
+ }
+ double probability(unsigned int r) const
+ {
+ double p = beta-alpha;
+ if(r == classes()-1)
+ return std::pow(1-p, static_cast<double>(r));
+ else
+ return p * std::pow(1-p, static_cast<double>(r));
+ }
+private:
+ double alpha, beta;
+ double low, high;
+};
+
+// poker experiment
+class poker_experiment : public experiment_base
+{
+public:
+ poker_experiment(unsigned int d, unsigned int k)
+ : experiment_base(k), range(d)
+ {
+ assert(range > 1);
+ }
+
+ template<class UniformRandomNumberGenerator, class Counter>
+ void run(UniformRandomNumberGenerator & f, Counter & count, int n) const
+ {
+ typedef typename UniformRandomNumberGenerator::result_type result_type;
+ assert(std::numeric_limits<result_type>::is_integer);
+ assert((f.min)() == 0);
+ assert((f.max)() == static_cast<result_type>(range-1));
+ std::vector<result_type> v(classes());
+ for(int i = 0; i < n; ++i) {
+ for(unsigned int j = 0; j < classes(); ++j)
+ v[j] = f();
+ std::sort(v.begin(), v.end());
+ result_type prev = v[0];
+ int r = 1; // count different values in v
+ for(unsigned int i = 1; i < classes(); ++i) {
+ if(prev != v[i]) {
+ prev = v[i];
+ ++r;
+ }
+ }
+ count(r-1);
+ }
+ }
+
+ double probability(unsigned int r) const
+ {
+ ++r; // transform to 1 <= r <= 5
+ double result = range;
+ for(unsigned int i = 1; i < r; ++i)
+ result *= range-i;
+ return result / std::pow(range, static_cast<double>(classes())) *
+ stirling2<double>(classes(), r);
+ }
+private:
+ unsigned int range;
+};
+
+// coupon collector experiment
+class coupon_collector_experiment : public experiment_base
+{
+public:
+ coupon_collector_experiment(unsigned int d, unsigned int cls)
+ : experiment_base(cls), d(d)
+ {
+ assert(d > 1);
+ }
+
+ template<class UniformRandomNumberGenerator, class Counter>
+ void run(UniformRandomNumberGenerator & f, Counter & count, int n) const
+ {
+ typedef typename UniformRandomNumberGenerator::result_type result_type;
+ assert(std::numeric_limits<result_type>::is_integer);
+ assert((f.min)() == 0);
+ assert((f.max)() == static_cast<result_type>(d-1));
+ std::vector<bool> occurs(d);
+ for(int i = 0; i < n; ++i) {
+ occurs.assign(d, false);
+ unsigned int r = 0; // length of current sequence
+ int q = 0; // number of non-duplicates in current set
+ for(;;) {
+ result_type val = f();
+ ++r;
+ if(!occurs[val]) { // new set element
+ occurs[val] = true;
+ ++q;
+ if(q == d)
+ break; // one complete set
+ }
+ }
+ count((std::min)(r-d, classes()-1));
+ }
+ }
+ double probability(unsigned int r) const
+ {
+ if(r == classes()-1)
+ return 1-fac<double>(d)/
+ std::pow(static_cast<double>(d), static_cast<double>(d+classes()-2)) *
+ stirling2<double>(d+classes()-2, d);
+ else
+ return fac<double>(d)/
+ std::pow(static_cast<double>(d), static_cast<double>(d+r)) *
+ stirling2<double>(d+r-1, d-1);
+ }
+private:
+ int d;
+};
+
+// permutation test
+class permutation_experiment : public equidistribution_experiment
+{
+public:
+ permutation_experiment(unsigned int t)
+ : equidistribution_experiment(fac<int>(t)), t(t)
+ {
+ assert(t > 1);
+ }
+
+ template<class UniformRandomNumberGenerator, class Counter>
+ void run(UniformRandomNumberGenerator & f, Counter & count, int n) const
+ {
+ typedef typename UniformRandomNumberGenerator::result_type result_type;
+ std::vector<result_type> v(t);
+ for(int i = 0; i < n; ++i) {
+ for(int j = 0; j < t; ++j) {
+ v[j] = f();
+ }
+ int x = 0;
+ for(int r = t-1; r > 0; r--) {
+ typename std::vector<result_type>::iterator it =
+ std::max_element(v.begin(), v.begin()+r+1);
+ x = (r+1)*x + (it-v.begin());
+ std::iter_swap(it, v.begin()+r);
+ }
+ count(x);
+ }
+ }
+private:
+ int t;
+};
+
+// birthday spacing experiment test
+class birthday_spacing_experiment : public experiment_base
+{
+public:
+ birthday_spacing_experiment(unsigned int d, int n, int m)
+ : experiment_base(d), n(n), m(m)
+ {
+ }
+
+ template<class UniformRandomNumberGenerator, class Counter>
+ void run(UniformRandomNumberGenerator & f, Counter & count, int n_total) const
+ {
+ typedef typename UniformRandomNumberGenerator::result_type result_type;
+ assert(std::numeric_limits<result_type>::is_integer);
+ assert((f.min)() == 0);
+ assert((f.max)() == static_cast<result_type>(m-1));
+
+ for(int j = 0; j < n_total; j++) {
+ std::vector<result_type> v(n);
+ std::generate_n(v.begin(), n, f);
+ std::sort(v.begin(), v.end());
+ std::vector<result_type> spacing(n);
+ for(int i = 0; i < n-1; i++)
+ spacing[i] = v[i+1]-v[i];
+ spacing[n-1] = v[0] + m - v[n-1];
+ std::sort(spacing.begin(), spacing.end());
+ unsigned int k = 0;
+ for(int i = 0; i < n-1; ++i) {
+ if(spacing[i] == spacing[i+1])
+ ++k;
+ }
+ count((std::min)(k, classes()-1));
+ }
+ }
+
+ double probability(unsigned int r) const
+ {
+ assert(classes() == 4);
+ assert(m == (1<<25));
+ assert(n == 512);
+ static const double prob[] = { 0.368801577, 0.369035243, 0.183471182,
+ 0.078691997 };
+ return prob[r];
+ }
+private:
+ int n, m;
+};
+/*
+ * Misc. helper functions.
+ */
+
+template<class Float>
+struct distribution_function
+{
+ typedef Float result_type;
+ typedef Float argument_type;
+ typedef Float first_argument_type;
+ typedef Float second_argument_type;
+};
+
+// computes P(K_n <= t) or P(t1 <= K_n <= t2). See Knuth, 3.3.1
+class kolmogorov_smirnov_probability : public distribution_function<double>
+{
+public:
+ kolmogorov_smirnov_probability(int n)
+ : approx(n > 50), n(n), sqrt_n(std::sqrt(double(n)))
+ {
+ if(!approx)
+ n_n = std::pow(static_cast<double>(n), n);
+ }
+
+ double cdf(double t) const
+ {
+ if(approx) {
+ return 1-std::exp(-2*t*t)*(1-2.0/3.0*t/sqrt_n);
+ } else {
+ t *= sqrt_n;
+ double sum = 0;
+ for(int k = static_cast<int>(std::ceil(t)); k <= n; k++)
+ sum += binomial<double>(n, k) * std::pow(k-t, k) *
+ std::pow(t+n-k, n-k-1);
+ return 1 - t/n_n * sum;
+ }
+ }
+ //double operator()(double t1, double t2) const
+ //{ return operator()(t2) - operator()(t1); }
+
+private:
+ bool approx;
+ int n;
+ double sqrt_n;
+ double n_n;
+};
+
+inline double cdf(const kolmogorov_smirnov_probability& dist, double val)
+{
+ return dist.cdf(val);
+}
+
+inline double quantile(const kolmogorov_smirnov_probability& dist, double val)
+{
+ return invert_monotone_inc(boost::bind(&cdf, dist, _1), val, 0.0, 1000.0);
+}
+
+/*
+ * Experiments for generators with continuous distribution functions
+ */
+class kolmogorov_experiment
+{
+public:
+ kolmogorov_experiment(int n) : n(n), ksp(n) { }
+ template<class NumberGenerator, class Distribution>
+ double run(NumberGenerator & gen, Distribution distrib) const
+ {
+ const int m = n;
+ typedef std::vector<double> saved_temp;
+ saved_temp a(m,1.0), b(m,0);
+ std::vector<int> c(m,0);
+ for(int i = 0; i < n; ++i) {
+ double val = static_cast<double>(gen());
+ double y = cdf(distrib, val);
+ int k = static_cast<int>(std::floor(m*y));
+ if(k >= m)
+ --k; // should not happen
+ a[k] = (std::min)(a[k], y);
+ b[k] = (std::max)(b[k], y);
+ ++c[k];
+ }
+ double kplus = 0, kminus = 0;
+ int j = 0;
+ for(int k = 0; k < m; ++k) {
+ if(c[k] > 0) {
+ kminus = (std::max)(kminus, a[k]-j/static_cast<double>(n));
+ j += c[k];
+ kplus = (std::max)(kplus, j/static_cast<double>(n) - b[k]);
+ }
+ }
+ kplus *= std::sqrt(double(n));
+ kminus *= std::sqrt(double(n));
+ // std::cout << "k+ " << kplus << " k- " << kminus << std::endl;
+ return kplus;
+ }
+ double probability(double x) const
+ {
+ return cdf(ksp, x);
+ }
+private:
+ int n;
+ kolmogorov_smirnov_probability ksp;
+};
+
+struct power_distribution
+{
+ power_distribution(double t) : t(t) {}
+ double t;
+};
+
+double cdf(const power_distribution& dist, double val)
+{
+ return std::pow(val, dist.t);
+}
+
+// maximum-of-t test (KS-based)
+template<class UniformRandomNumberGenerator>
+class maximum_experiment
+{
+public:
+ typedef UniformRandomNumberGenerator base_type;
+ maximum_experiment(base_type & f, int n, int t) : f(f), ke(n), t(t)
+ { }
+
+ double operator()() const
+ {
+ generator gen(f, t);
+ return ke.run(gen, power_distribution(t));
+ }
+
+private:
+ struct generator {
+ generator(base_type & f, int t) : f(f, boost::uniform_01<>()), t(t) { }
+ double operator()()
+ {
+ double mx = f();
+ for(int i = 1; i < t; ++i)
+ mx = (std::max)(mx, f());
+ return mx;
+ }
+ private:
+ boost::variate_generator<base_type&, boost::uniform_01<> > f;
+ int t;
+ };
+ base_type & f;
+ kolmogorov_experiment ke;
+ int t;
+};
+
+// compute a chi-square value for the distribution approximation error
+template<class ForwardIterator, class UnaryFunction>
+typename UnaryFunction::result_type
+chi_square_value(ForwardIterator first, ForwardIterator last,
+ UnaryFunction probability)
+{
+ typedef std::iterator_traits<ForwardIterator> iter_traits;
+ typedef typename iter_traits::value_type counter_type;
+ typedef typename UnaryFunction::result_type result_type;
+ unsigned int classes = std::distance(first, last);
+ result_type sum = 0;
+ counter_type n = 0;
+ for(unsigned int i = 0; i < classes; ++first, ++i) {
+ counter_type count = *first;
+ n += count;
+ sum += (count/probability(i)) * count; // avoid overflow
+ }
+#if 0
+ for(unsigned int i = 0; i < classes; ++i) {
+ // std::cout << (n*probability(i)) << " ";
+ if(n * probability(i) < 5)
+ std::cerr << "Not enough test runs for slot " << i
+ << " p=" << probability(i) << ", n=" << n
+ << std::endl;
+ }
+#endif
+ // std::cout << std::endl;
+ // throw std::invalid_argument("not enough test runs");
+
+ return sum/n - n;
+}
+template<class RandomAccessContainer>
+class generic_counter
+{
+public:
+ explicit generic_counter(unsigned int classes) : container(classes, 0) { }
+ void operator()(int i)
+ {
+ assert(i >= 0);
+ assert(static_cast<unsigned int>(i) < container.size());
+ ++container[i];
+ }
+ typename RandomAccessContainer::const_iterator begin() const
+ { return container.begin(); }
+ typename RandomAccessContainer::const_iterator end() const
+ { return container.end(); }
+
+private:
+ RandomAccessContainer container;
+};
+
+// chi_square test
+template<class Experiment, class Generator>
+double run_experiment(const Experiment & experiment, Generator & gen, int n)
+{
+ generic_counter<std::vector<int> > v(experiment.classes());
+ experiment.run(gen, v, n);
+ return chi_square_value(v.begin(), v.end(),
+ boost::bind(&Experiment::probability,
+ experiment, boost::placeholders::_1));
+}
+
+// chi_square test
+template<class Experiment, class Generator>
+double run_experiment(const Experiment & experiment, const Generator & gen, int n)
+{
+ generic_counter<std::vector<int> > v(experiment.classes());
+ experiment.run(gen, v, n);
+ return chi_square_value(v.begin(), v.end(),
+ boost::bind(&Experiment::probability,
+ experiment, boost::placeholders::_1));
+}
+
+// number generator with experiment results (for nesting)
+template<class Experiment, class Generator>
+class experiment_generator_t
+{
+public:
+ experiment_generator_t(const Experiment & exper, Generator & gen, int n)
+ : experiment(exper), generator(gen), n(n) { }
+ double operator()() const { return run_experiment(experiment, generator, n); }
+private:
+ const Experiment & experiment;
+ Generator & generator;
+ int n;
+};
+
+template<class Experiment, class Generator>
+experiment_generator_t<Experiment, Generator>
+experiment_generator(const Experiment & e, Generator & gen, int n)
+{
+ return experiment_generator_t<Experiment, Generator>(e, gen, n);
+}
+
+
+template<class Experiment, class Generator, class Distribution>
+class ks_experiment_generator_t
+{
+public:
+ ks_experiment_generator_t(const Experiment & exper, Generator & gen,
+ const Distribution & distrib)
+ : experiment(exper), generator(gen), distribution(distrib) { }
+ double operator()() const { return experiment.run(generator, distribution); }
+private:
+ const Experiment & experiment;
+ Generator & generator;
+ Distribution distribution;
+};
+
+template<class Experiment, class Generator, class Distribution>
+ks_experiment_generator_t<Experiment, Generator, Distribution>
+ks_experiment_generator(const Experiment & e, Generator & gen,
+ const Distribution & distrib)
+{
+ return ks_experiment_generator_t<Experiment, Generator, Distribution>
+ (e, gen, distrib);
+}
+
+
+#endif /* STATISTIC_TESTS_HPP */
+
diff --git a/src/boost/libs/random/test/test_bernoulli.cpp b/src/boost/libs/random/test/test_bernoulli.cpp
new file mode 100644
index 000000000..cab0c1c3e
--- /dev/null
+++ b/src/boost/libs/random/test/test_bernoulli.cpp
@@ -0,0 +1,108 @@
+/* test_bernoulli.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/bernoulli_distribution.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_01.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/math/distributions/binomial.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+#include <vector>
+#include <iostream>
+#include <numeric>
+
+#include "chi_squared_test.hpp"
+
+bool do_test(double p, long long max) {
+ std::cout << "running bernoulli(" << p << ")" << " " << max << " times: " << std::flush;
+
+ boost::math::binomial expected(static_cast<double>(max), p);
+
+ boost::random::bernoulli_distribution<> dist(p);
+ boost::mt19937 gen;
+ long long count = 0;
+ for(long long i = 0; i < max; ++i) {
+ if(dist(gen)) ++count;
+ }
+
+ double prob = cdf(expected, count);
+
+ bool result = prob < 0.99 && prob > 0.01;
+ const char* err = result? "" : "*";
+ std::cout << std::setprecision(17) << prob << err << std::endl;
+
+ std::cout << std::setprecision(6);
+
+ return result;
+}
+
+bool do_tests(int repeat, long long trials) {
+ boost::mt19937 gen;
+ boost::uniform_01<> rdist;
+ int errors = 0;
+ for(int i = 0; i < repeat; ++i) {
+ if(!do_test(rdist(gen), trials)) {
+ ++errors;
+ }
+ }
+ if(errors != 0) {
+ std::cout << "*** " << errors << " errors detected ***" << std::endl;
+ }
+ return errors == 0;
+}
+
+int usage() {
+ std::cerr << "Usage: test_bernoulli_distribution -r <repeat> -t <trials>" << std::endl;
+ return 2;
+}
+
+template<class T>
+bool handle_option(int& argc, char**& argv, char opt, T& value) {
+ if(argv[0][1] == opt && argc > 1) {
+ --argc;
+ ++argv;
+ value = boost::lexical_cast<T>(argv[0]);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+int main(int argc, char** argv) {
+ int repeat = 10;
+ long long trials = 1000000ll;
+
+ if(argc > 0) {
+ --argc;
+ ++argv;
+ }
+ while(argc > 0) {
+ if(argv[0][0] != '-') return usage();
+ else if(!handle_option(argc, argv, 'r', repeat)
+ && !handle_option(argc, argv, 't', trials)) {
+ return usage();
+ }
+ --argc;
+ ++argv;
+ }
+
+ try {
+ if(do_tests(repeat, trials)) {
+ return 0;
+ } else {
+ return EXIT_FAILURE;
+ }
+ } catch(...) {
+ std::cerr << boost::current_exception_diagnostic_information() << std::endl;
+ return EXIT_FAILURE;
+ }
+}
diff --git a/src/boost/libs/random/test/test_bernoulli_distribution.cpp b/src/boost/libs/random/test/test_bernoulli_distribution.cpp
new file mode 100644
index 000000000..ca021ce62
--- /dev/null
+++ b/src/boost/libs/random/test/test_bernoulli_distribution.cpp
@@ -0,0 +1,32 @@
+/* test_bernoulli_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/bernoulli_distribution.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::bernoulli_distribution<>
+#define BOOST_RANDOM_ARG1 p
+#define BOOST_RANDOM_ARG1_DEFAULT 0.5
+#define BOOST_RANDOM_ARG1_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN false
+#define BOOST_RANDOM_DIST0_MAX true
+#define BOOST_RANDOM_DIST1_MIN false
+#define BOOST_RANDOM_DIST1_MAX true
+
+#define BOOST_RANDOM_TEST1_PARAMS (0.0)
+#define BOOST_RANDOM_TEST1_MIN false
+#define BOOST_RANDOM_TEST1_MAX false
+
+#define BOOST_RANDOM_TEST2_PARAMS (1.0)
+#define BOOST_RANDOM_TEST2_MIN true
+#define BOOST_RANDOM_TEST2_MAX true
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_beta.cpp b/src/boost/libs/random/test/test_beta.cpp
new file mode 100644
index 000000000..7b47bee23
--- /dev/null
+++ b/src/boost/libs/random/test/test_beta.cpp
@@ -0,0 +1,28 @@
+/* test_beta.cpp
+ *
+ * Copyright Steven Watanabe 2014
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/beta_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/beta.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::beta_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME beta
+#define BOOST_MATH_DISTRIBUTION boost::math::beta_distribution<>
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME alpha
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME beta
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_beta_distribution.cpp b/src/boost/libs/random/test/test_beta_distribution.cpp
new file mode 100644
index 000000000..4d66b017e
--- /dev/null
+++ b/src/boost/libs/random/test/test_beta_distribution.cpp
@@ -0,0 +1,38 @@
+/* test_beta_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2014
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/beta_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::beta_distribution<>
+#define BOOST_RANDOM_ARG1 alpha
+#define BOOST_RANDOM_ARG2 beta
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX 1
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX 1
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX 1
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 1.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (1.0, 1000000.0)
+#define BOOST_RANDOM_TEST2_MIN 0.0
+#define BOOST_RANDOM_TEST2_MAX 1.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_binomial.cpp b/src/boost/libs/random/test/test_binomial.cpp
new file mode 100644
index 000000000..51e707ac3
--- /dev/null
+++ b/src/boost/libs/random/test/test_binomial.cpp
@@ -0,0 +1,30 @@
+/* test_binomial.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/binomial_distribution.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_01.hpp>
+#include <boost/math/distributions/binomial.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::binomial_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME binomial
+#define BOOST_MATH_DISTRIBUTION boost::math::binomial
+#define BOOST_RANDOM_ARG1_TYPE int
+#define BOOST_RANDOM_ARG1_NAME n
+#define BOOST_RANDOM_ARG1_DEFAULT 100000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_int<>(0, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME p
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_01<>()
+#define BOOST_RANDOM_DISTRIBUTION_MAX n
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_binomial_distribution.cpp b/src/boost/libs/random/test/test_binomial_distribution.cpp
new file mode 100644
index 000000000..47e80d692
--- /dev/null
+++ b/src/boost/libs/random/test/test_binomial_distribution.cpp
@@ -0,0 +1,37 @@
+/* test_binomial_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/binomial_distribution.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::binomial_distribution<>
+#define BOOST_RANDOM_ARG1 t
+#define BOOST_RANDOM_ARG2 p
+#define BOOST_RANDOM_ARG1_DEFAULT 1
+#define BOOST_RANDOM_ARG2_DEFAULT 0.5
+#define BOOST_RANDOM_ARG1_VALUE 10
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX 1
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX 10
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX 10
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 1
+
+#define BOOST_RANDOM_TEST2_PARAMS (10, 0.25)
+#define BOOST_RANDOM_TEST2_MIN 0
+#define BOOST_RANDOM_TEST2_MAX 10
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_cauchy.cpp b/src/boost/libs/random/test/test_cauchy.cpp
new file mode 100644
index 000000000..14c27d9a6
--- /dev/null
+++ b/src/boost/libs/random/test/test_cauchy.cpp
@@ -0,0 +1,28 @@
+/* test_cauchy.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/cauchy_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/cauchy.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::cauchy_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME cauchy
+#define BOOST_MATH_DISTRIBUTION boost::math::cauchy
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME median
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(-n, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME sigma
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_cauchy_distribution.cpp b/src/boost/libs/random/test/test_cauchy_distribution.cpp
new file mode 100644
index 000000000..845ac7cfb
--- /dev/null
+++ b/src/boost/libs/random/test/test_cauchy_distribution.cpp
@@ -0,0 +1,35 @@
+/* test_cauchy_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/cauchy_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::cauchy_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 0.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS (-100000.0, 0.000001)
+#define BOOST_RANDOM_TEST2_PARAMS (100000.0, 0.000001)
+#define BOOST_RANDOM_TEST1_MAX 0.0
+#define BOOST_RANDOM_TEST2_MIN 0.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_chi_squared.cpp b/src/boost/libs/random/test/test_chi_squared.cpp
new file mode 100644
index 000000000..c315765f7
--- /dev/null
+++ b/src/boost/libs/random/test/test_chi_squared.cpp
@@ -0,0 +1,24 @@
+/* test_chi_squared.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/chi_squared_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/chi_squared.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::chi_squared_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME chi_squared
+#define BOOST_MATH_DISTRIBUTION boost::math::chi_squared
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME n
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_chi_squared_distribution.cpp b/src/boost/libs/random/test/test_chi_squared_distribution.cpp
new file mode 100644
index 000000000..1df9f7e61
--- /dev/null
+++ b/src/boost/libs/random/test/test_chi_squared_distribution.cpp
@@ -0,0 +1,34 @@
+/* test_chi_squared_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/chi_squared_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::chi_squared_distribution<>
+#define BOOST_RANDOM_ARG1 n
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 100.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (10000.0)
+#define BOOST_RANDOM_TEST2_MIN 100.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_const_mod.cpp b/src/boost/libs/random/test/test_const_mod.cpp
new file mode 100644
index 000000000..5d18eba7e
--- /dev/null
+++ b/src/boost/libs/random/test/test_const_mod.cpp
@@ -0,0 +1,183 @@
+/* test_const_mod.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/detail/const_mod.hpp>
+
+#include <boost/cstdint.hpp>
+#include <boost/mpl/vector.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+typedef boost::mpl::vector<
+ boost::int8_t,
+ boost::uint8_t
+> int8_types;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_mult8, IntType, int8_types) {
+ for(int i = 0; i < 127; ++i) {
+ for(int j = 0; j < 127; ++j) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 127>::mult(IntType(i), IntType(j))), i * j % 127);
+ }
+ }
+ int modulus = (std::numeric_limits<IntType>::max)() + 1;
+ for(int i = 0; i < modulus; ++i) {
+ for(int j = 0; j < modulus; ++j) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 0>::mult(IntType(i), IntType(j))), i * j % modulus);
+ }
+ }
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_add8, IntType, int8_types) {
+ for(int i = 0; i < 127; ++i) {
+ for(int j = 0; j < 127; ++j) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 127>::add(IntType(i), IntType(j))), (i + j) % 127);
+ }
+ }
+ {
+ const int modulus = boost::integer_traits<IntType>::const_max;
+ for(int i = 0; i < modulus; ++i) {
+ for(int j = 0; j < modulus; ++j) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, modulus>::add(IntType(i), IntType(j))), (i + j) % modulus);
+ }
+ }
+ }
+ {
+ int modulus = (std::numeric_limits<IntType>::max)() + 1;
+ for(int i = 0; i < modulus; ++i) {
+ for(int j = 0; j < modulus; ++j) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 0>::add(IntType(i), IntType(j))), (i + j) % modulus);
+ }
+ }
+ }
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_mult_add8, IntType, int8_types) {
+ for(int i = 0; i < 127; i += 5) {
+ for(int j = 0; j < 127; j += 3) {
+ for(int k = 0; k < 127; k += 3) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 127>::mult_add(IntType(i), IntType(j), IntType(k))), (i * j + k) % 127);
+ }
+ }
+ }
+ {
+ int modulus = (std::numeric_limits<IntType>::max)() + 1;
+ for(int i = 0; i < modulus; i += 5) {
+ for(int j = 0; j < modulus; j += 3) {
+ for(int k = 0; k < modulus; k += 3) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 0>::mult_add(IntType(i), IntType(j), IntType(k))), (i * j + k) % modulus);
+ }
+ }
+ }
+ }
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_invert8, IntType, int8_types) {
+ for(int i = 1; i < 127; ++i) {
+ IntType inverse = boost::random::const_mod<IntType, 127>::invert(IntType(i));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 127>::mult(IntType(i), inverse)), 1);
+ }
+ int modulus = (std::numeric_limits<IntType>::max)() + 1;
+ for(int i = 1; i < modulus; i += 2) {
+ IntType inverse = boost::random::const_mod<IntType, 0>::invert(IntType(i));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 0>::mult(IntType(i), inverse)), 1);
+ }
+}
+
+typedef boost::mpl::vector<
+ boost::int32_t,
+ boost::uint32_t
+> int32_types;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_mult32, IntType, int32_types) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult(0, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult(0, 2147483562)), IntType(0));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult(2147483562, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult(2147483562, 2147483562)), IntType(1));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult(1234567890, 1234657890)), IntType(813106682));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_add32, IntType, int32_types) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::add(0, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::add(0, 2147483562)), IntType(2147483562));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::add(2147483562, 0)), IntType(2147483562));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::add(2147483562, 2147483562)), IntType(2147483561));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::add(1234567890, 1234657890)), IntType(321742217));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_mult_add32, IntType, int32_types) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult_add(0, 0, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult_add(0, 2147483562, 827364)), IntType(827364));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult_add(2147483562, 0, 827364)), IntType(827364));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult_add(2147483562, 2147483562, 2147483562)), IntType(0));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult_add(1234567890, 1234657890, 1726384759)), IntType(392007878));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_invert32, IntType, int32_types) {
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::invert(0)), IntType(0));
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult_add(0, 0, 0)), IntType(0));
+ IntType inverse;
+ inverse = boost::random::const_mod<IntType, 2147483563>::invert(2147483562);
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult(2147483562, inverse)), IntType(1));
+ inverse = boost::random::const_mod<IntType, 2147483563>::invert(1234567890);
+ BOOST_CHECK_EQUAL((boost::random::const_mod<IntType, 2147483563>::mult(1234567890, inverse)), IntType(1));
+}
+
+#if !defined(BOOST_NO_INT64_T)
+
+typedef boost::mpl::vector<
+ boost::int64_t,
+ boost::uint64_t
+> int64_types;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_mult64, IntType, int64_types) {
+ typedef boost::random::const_mod<IntType, INT64_C(2147483563652738498)> const_mod_type;
+ BOOST_CHECK_EQUAL((const_mod_type::mult(0, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((const_mod_type::mult(0, 2147483562)), IntType(0));
+ BOOST_CHECK_EQUAL((const_mod_type::mult(2147483562, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((const_mod_type::mult(2147483562, 2147483562)), IntType(INT64_C(316718521754730848)));
+ BOOST_CHECK_EQUAL((const_mod_type::mult(1234567890, 1234657890)), IntType(INT64_C(1524268986129152100)));
+ BOOST_CHECK_EQUAL((const_mod_type::mult(INT64_C(1234567890726352938), INT64_C(1234657890736453927))), IntType(INT64_C(88656187017794672)));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_add64, IntType, int64_types) {
+ typedef boost::random::const_mod<IntType, INT64_C(2147483563652738498)> const_mod_type;
+ BOOST_CHECK_EQUAL((const_mod_type::add(0, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((const_mod_type::add(0, 2147483562)), IntType(2147483562));
+ BOOST_CHECK_EQUAL((const_mod_type::add(2147483562, 0)), IntType(2147483562));
+ BOOST_CHECK_EQUAL((const_mod_type::add(2147483562, 2147483562)), IntType(4294967124U));
+ BOOST_CHECK_EQUAL((const_mod_type::add(1234567890, 1234657890)), IntType(2469225780U));
+ BOOST_CHECK_EQUAL((const_mod_type::add(INT64_C(1234567890726352938), INT64_C(1234657890736453927))), IntType(INT64_C(321742217810068367)));
+ BOOST_CHECK_EQUAL((const_mod_type::add(INT64_C(2147483563652738490), 8)), IntType(0));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_mult_add64, IntType, int64_types) {
+ typedef boost::random::const_mod<IntType, INT64_C(2147483563652738498)> const_mod_type;
+ BOOST_CHECK_EQUAL((const_mod_type::mult_add(0, 0, 0)), IntType(0));
+ BOOST_CHECK_EQUAL((const_mod_type::mult_add(0, 2147483562, 827364)), IntType(827364));
+ BOOST_CHECK_EQUAL((const_mod_type::mult_add(2147483562, 0, 827364)), IntType(827364));
+ BOOST_CHECK_EQUAL((const_mod_type::mult_add(2147483562, 2147483562, 2147483562)), IntType(INT64_C(316718523902214410)));
+ BOOST_CHECK_EQUAL((const_mod_type::mult_add(1234567890, 1234657890, 1726384759)), IntType(INT64_C(1524268987855536859)));
+ BOOST_CHECK_EQUAL((const_mod_type::mult_add(INT64_C(1234567890726352938), INT64_C(1234657890736453927), INT64_C(1726384759726488649))), IntType(INT64_C(1815040946744283321)));
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_invert64, IntType, int64_types) {
+ typedef boost::random::const_mod<IntType, INT64_C(2147483563652738498)> const_mod_type;
+ BOOST_CHECK_EQUAL((const_mod_type::invert(0)), IntType(0));
+ BOOST_CHECK_EQUAL((const_mod_type::mult_add(0, 0, 0)), IntType(0));
+ IntType inverse;
+ inverse = const_mod_type::invert(INT64_C(7362947769));
+ BOOST_CHECK_EQUAL((const_mod_type::mult(INT64_C(7362947769), inverse)), IntType(1));
+ inverse = const_mod_type::invert(INT64_C(1263142436887493875));
+ BOOST_CHECK_EQUAL((const_mod_type::mult(INT64_C(1263142436887493875), inverse)), IntType(1));
+}
+
+#endif
diff --git a/src/boost/libs/random/test/test_discrete.cpp b/src/boost/libs/random/test/test_discrete.cpp
new file mode 100644
index 000000000..f753e62cd
--- /dev/null
+++ b/src/boost/libs/random/test/test_discrete.cpp
@@ -0,0 +1,123 @@
+/* test_poisson.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/discrete_distribution.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+#include <vector>
+#include <iostream>
+#include <numeric>
+
+#include "chi_squared_test.hpp"
+
+bool do_test(int n, long long max) {
+ std::cout << "running discrete(p0, p1, ..., p" << n-1 << ")" << " " << max << " times: " << std::flush;
+
+ std::vector<double> expected;
+ {
+ boost::mt19937 egen;
+ for(int i = 0; i < n; ++i) {
+ expected.push_back(egen());
+ }
+ double sum = std::accumulate(expected.begin(), expected.end(), 0.0);
+ for(std::vector<double>::iterator iter = expected.begin(), end = expected.end(); iter != end; ++iter) {
+ *iter /= sum;
+ }
+ }
+
+ boost::random::discrete_distribution<> dist(expected);
+ boost::mt19937 gen;
+ std::vector<long long> results(expected.size());
+ for(long long i = 0; i < max; ++i) {
+ ++results[dist(gen)];
+ }
+
+ long long sum = std::accumulate(results.begin(), results.end(), 0ll);
+ if(sum != max) {
+ std::cout << "*** Failed: incorrect total: " << sum << " ***" << std::endl;
+ return false;
+ }
+ double chsqr = chi_squared_test(results, expected, max);
+
+ bool result = chsqr < 0.99;
+ const char* err = result? "" : "*";
+ std::cout << std::setprecision(17) << chsqr << err << std::endl;
+
+ std::cout << std::setprecision(6);
+
+ return result;
+}
+
+bool do_tests(int repeat, int max_n, long long trials) {
+ boost::mt19937 gen;
+ boost::uniform_int<> idist(1, max_n);
+ int errors = 0;
+ for(int i = 0; i < repeat; ++i) {
+ if(!do_test(idist(gen), trials)) {
+ ++errors;
+ }
+ }
+ if(errors != 0) {
+ std::cout << "*** " << errors << " errors detected ***" << std::endl;
+ }
+ return errors == 0;
+}
+
+int usage() {
+ std::cerr << "Usage: test_discrete -r <repeat> -n <max n> -t <trials>" << std::endl;
+ return 2;
+}
+
+template<class T>
+bool handle_option(int& argc, char**& argv, char opt, T& value) {
+ if(argv[0][1] == opt && argc > 1) {
+ --argc;
+ ++argv;
+ value = boost::lexical_cast<T>(argv[0]);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+int main(int argc, char** argv) {
+ int repeat = 10;
+ int max_n = 10000;
+ long long trials = 1000000ll;
+
+ if(argc > 0) {
+ --argc;
+ ++argv;
+ }
+ while(argc > 0) {
+ if(argv[0][0] != '-') return usage();
+ else if(!handle_option(argc, argv, 'r', repeat)
+ && !handle_option(argc, argv, 'n', max_n)
+ && !handle_option(argc, argv, 't', trials)) {
+ return usage();
+ }
+ --argc;
+ ++argv;
+ }
+
+ try {
+ if(do_tests(repeat, max_n, trials)) {
+ return 0;
+ } else {
+ return EXIT_FAILURE;
+ }
+ } catch(...) {
+ std::cerr << boost::current_exception_diagnostic_information() << std::endl;
+ return EXIT_FAILURE;
+ }
+}
diff --git a/src/boost/libs/random/test/test_discrete_distribution.cpp b/src/boost/libs/random/test/test_discrete_distribution.cpp
new file mode 100644
index 000000000..e14bc6430
--- /dev/null
+++ b/src/boost/libs/random/test/test_discrete_distribution.cpp
@@ -0,0 +1,168 @@
+/* test_discrete_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/discrete_distribution.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/assign/list_of.hpp>
+#include <sstream>
+#include <vector>
+#include "concepts.hpp"
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using boost::random::test::RandomNumberDistribution;
+using boost::random::discrete_distribution;
+BOOST_CONCEPT_ASSERT((RandomNumberDistribution< discrete_distribution<> >));
+
+struct gen {
+ double operator()(double arg) {
+ if(arg < 100) return 100;
+ else if(arg < 103) return 1;
+ else if(arg < 107) return 2;
+ else if(arg < 111) return 1;
+ else if(arg < 114) return 4;
+ else return 100;
+ }
+};
+
+#define CHECK_PROBABILITIES(actual, expected) \
+ do { \
+ std::vector<double> _actual = (actual); \
+ std::vector<double> _expected = (expected); \
+ BOOST_CHECK_EQUAL_COLLECTIONS( \
+ _actual.begin(), _actual.end(), \
+ _expected.begin(), _expected.end()); \
+ } while(false)
+
+using boost::assign::list_of;
+
+BOOST_AUTO_TEST_CASE(test_constructors) {
+ boost::random::discrete_distribution<> dist;
+ CHECK_PROBABILITIES(dist.probabilities(), list_of(1.0));
+
+#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+ boost::random::discrete_distribution<> dist_il = { 1, 2, 1, 4 };
+ CHECK_PROBABILITIES(dist_il.probabilities(), list_of(.125)(.25)(.125)(.5));
+#endif
+ std::vector<double> probs = boost::assign::list_of(1.0)(2.0)(1.0)(4.0);
+
+ boost::random::discrete_distribution<> dist_r(probs);
+ CHECK_PROBABILITIES(dist_r.probabilities(), list_of(.125)(.25)(.125)(.5));
+
+ boost::random::discrete_distribution<> dist_it(probs.begin(), probs.end());
+ CHECK_PROBABILITIES(dist_it.probabilities(), list_of(.125)(.25)(.125)(.5));
+
+ boost::random::discrete_distribution<> dist_fun(4, 99, 115, gen());
+ CHECK_PROBABILITIES(dist_fun.probabilities(), list_of(.125)(.25)(.125)(.5));
+
+ boost::random::discrete_distribution<> copy(dist);
+ BOOST_CHECK_EQUAL(dist, copy);
+ boost::random::discrete_distribution<> copy_r(dist_r);
+ BOOST_CHECK_EQUAL(dist_r, copy_r);
+
+ boost::random::discrete_distribution<> notpow2(3, 99, 111, gen());
+ BOOST_REQUIRE_EQUAL(notpow2.probabilities().size(), 3u);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.probabilities()[0], 0.25, 0.00000000001);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.probabilities()[1], 0.50, 0.00000000001);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.probabilities()[2], 0.25, 0.00000000001);
+ boost::random::discrete_distribution<> copy_notpow2(notpow2);
+ BOOST_CHECK_EQUAL(notpow2, copy_notpow2);
+}
+
+BOOST_AUTO_TEST_CASE(test_param) {
+ std::vector<double> probs = boost::assign::list_of(1.0)(2.0)(1.0)(4.0);
+ boost::random::discrete_distribution<> dist(probs);
+ boost::random::discrete_distribution<>::param_type param = dist.param();
+ CHECK_PROBABILITIES(param.probabilities(), list_of(.125)(.25)(.125)(.5));
+ boost::random::discrete_distribution<> copy1(param);
+ BOOST_CHECK_EQUAL(dist, copy1);
+ boost::random::discrete_distribution<> copy2;
+ copy2.param(param);
+ BOOST_CHECK_EQUAL(dist, copy2);
+
+ boost::random::discrete_distribution<>::param_type param_copy = param;
+ BOOST_CHECK_EQUAL(param, param_copy);
+ BOOST_CHECK(param == param_copy);
+ BOOST_CHECK(!(param != param_copy));
+ boost::random::discrete_distribution<>::param_type param_default;
+ CHECK_PROBABILITIES(param_default.probabilities(), list_of(1.0));
+ BOOST_CHECK(param != param_default);
+ BOOST_CHECK(!(param == param_default));
+
+#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+ boost::random::discrete_distribution<>::param_type
+ parm_il = { 1, 2, 1, 4 };
+ CHECK_PROBABILITIES(parm_il.probabilities(), list_of(.125)(.25)(.125)(.5));
+#endif
+
+ boost::random::discrete_distribution<>::param_type parm_r(probs);
+ CHECK_PROBABILITIES(parm_r.probabilities(), list_of(.125)(.25)(.125)(.5));
+
+ boost::random::discrete_distribution<>::param_type
+ parm_it(probs.begin(), probs.end());
+ CHECK_PROBABILITIES(parm_it.probabilities(), list_of(.125)(.25)(.125)(.5));
+
+ boost::random::discrete_distribution<>::param_type
+ parm_fun(4, 99, 115, gen());
+ CHECK_PROBABILITIES(parm_fun.probabilities(), list_of(.125)(.25)(.125)(.5));
+}
+
+BOOST_AUTO_TEST_CASE(test_min_max) {
+ std::vector<double> probs = boost::assign::list_of(1.0)(2.0)(1.0);
+ boost::random::discrete_distribution<> dist;
+ BOOST_CHECK_EQUAL((dist.min)(), 0);
+ BOOST_CHECK_EQUAL((dist.max)(), 0);
+ boost::random::discrete_distribution<> dist_r(probs);
+ BOOST_CHECK_EQUAL((dist_r.min)(), 0);
+ BOOST_CHECK_EQUAL((dist_r.max)(), 2);
+}
+
+BOOST_AUTO_TEST_CASE(test_comparison) {
+ std::vector<double> probs = boost::assign::list_of(1.0)(2.0)(1.0)(4.0);
+ boost::random::discrete_distribution<> dist;
+ boost::random::discrete_distribution<> dist_copy(dist);
+ boost::random::discrete_distribution<> dist_r(probs);
+ boost::random::discrete_distribution<> dist_r_copy(dist_r);
+ BOOST_CHECK(dist == dist_copy);
+ BOOST_CHECK(!(dist != dist_copy));
+ BOOST_CHECK(dist_r == dist_r_copy);
+ BOOST_CHECK(!(dist_r != dist_r_copy));
+ BOOST_CHECK(dist != dist_r);
+ BOOST_CHECK(!(dist == dist_r));
+}
+
+BOOST_AUTO_TEST_CASE(test_streaming) {
+ std::vector<double> probs = boost::assign::list_of(1.0)(2.0)(1.0)(4.0);
+ boost::random::discrete_distribution<> dist(probs);
+ std::stringstream stream;
+ stream << dist;
+ boost::random::discrete_distribution<> restored_dist;
+ stream >> restored_dist;
+ BOOST_CHECK_EQUAL(dist, restored_dist);
+}
+
+BOOST_AUTO_TEST_CASE(test_generation) {
+ std::vector<double> probs = boost::assign::list_of(0.0)(1.0);
+ boost::minstd_rand0 gen;
+ boost::random::discrete_distribution<> dist;
+ boost::random::discrete_distribution<> dist_r(probs);
+ for(int i = 0; i < 10; ++i) {
+ int value = dist(gen);
+ BOOST_CHECK_EQUAL(value, 0);
+ int value_r = dist_r(gen);
+ BOOST_CHECK_EQUAL(value_r, 1);
+ int value_param = dist_r(gen, dist.param());
+ BOOST_CHECK_EQUAL(value_param, 0);
+ int value_r_param = dist(gen, dist_r.param());
+ BOOST_CHECK_EQUAL(value_r_param, 1);
+ }
+}
diff --git a/src/boost/libs/random/test/test_distribution.ipp b/src/boost/libs/random/test/test_distribution.ipp
new file mode 100644
index 000000000..69f17d988
--- /dev/null
+++ b/src/boost/libs/random/test/test_distribution.ipp
@@ -0,0 +1,290 @@
+/* test_distribution.ipp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
+#include <sstream>
+#include "concepts.hpp"
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using boost::random::test::RandomNumberDistribution;
+BOOST_CONCEPT_ASSERT((RandomNumberDistribution< BOOST_RANDOM_DISTRIBUTION >));
+
+BOOST_AUTO_TEST_CASE(test_constructors) {
+ BOOST_RANDOM_DISTRIBUTION dist;
+ BOOST_CHECK_EQUAL(dist.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_DEFAULT);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(dist.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK_EQUAL(dist.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_DEFAULT);
+#endif
+ BOOST_RANDOM_DISTRIBUTION dist_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(dist_one.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(dist_one.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK_EQUAL(dist_one.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL(dist_two.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(dist_two.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK_EQUAL(dist_two.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_DEFAULT);
+#endif
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_RANDOM_DISTRIBUTION dist_three(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE, BOOST_RANDOM_ARG3_VALUE);
+ BOOST_CHECK_EQUAL(dist_three.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(dist_three.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL(dist_three.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_VALUE);
+#endif
+ BOOST_RANDOM_DISTRIBUTION copy(dist);
+ BOOST_CHECK_EQUAL(dist, copy);
+ BOOST_RANDOM_DISTRIBUTION copy_one(dist_one);
+ BOOST_CHECK_EQUAL(dist_one, copy_one);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION copy_two(dist_two);
+ BOOST_CHECK_EQUAL(dist_two, copy_two);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_RANDOM_DISTRIBUTION copy_three(dist_three);
+ BOOST_CHECK_EQUAL(dist_three, copy_three);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_param) {
+#if defined(BOOST_RANDOM_ARG3)
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE, BOOST_RANDOM_ARG3_VALUE);
+#elif defined(BOOST_RANDOM_ARG2)
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+#else
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE);
+#endif
+ BOOST_RANDOM_DISTRIBUTION::param_type param = dist.param();
+ BOOST_CHECK_EQUAL(param.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(param.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK_EQUAL(param.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_VALUE);
+#endif
+ BOOST_RANDOM_DISTRIBUTION copy1(param);
+ BOOST_CHECK_EQUAL(dist, copy1);
+ BOOST_RANDOM_DISTRIBUTION copy2;
+ copy2.param(param);
+ BOOST_CHECK_EQUAL(dist, copy2);
+
+ BOOST_RANDOM_DISTRIBUTION::param_type param_copy = param;
+ BOOST_CHECK_EQUAL(param, param_copy);
+ BOOST_CHECK(param == param_copy);
+ BOOST_CHECK(!(param != param_copy));
+ BOOST_RANDOM_DISTRIBUTION::param_type param_default;
+ BOOST_CHECK_EQUAL(param_default.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_DEFAULT);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(param_default.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK_EQUAL(param_default.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_DEFAULT);
+#endif
+ BOOST_CHECK(param != param_default);
+ BOOST_CHECK(!(param == param_default));
+ BOOST_RANDOM_DISTRIBUTION::param_type param_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(param_one.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK_EQUAL(param_one.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK_EQUAL(param_one.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_DEFAULT);
+#endif
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK(param != param_one);
+ BOOST_CHECK(!(param == param_one));
+#endif
+ BOOST_CHECK(param_default != param_one);
+ BOOST_CHECK(!(param_default == param_one));
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION::param_type param_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL(param_two.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(param_two.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK_EQUAL(param_two.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_DEFAULT);
+#endif
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_RANDOM_DISTRIBUTION::param_type param_three(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE, BOOST_RANDOM_ARG3_VALUE);
+ BOOST_CHECK_EQUAL(param_three.BOOST_RANDOM_ARG1(), BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL(param_three.BOOST_RANDOM_ARG2(), BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL(param_three.BOOST_RANDOM_ARG3(), BOOST_RANDOM_ARG3_VALUE);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_min_max) {
+ BOOST_RANDOM_DISTRIBUTION dist;
+ BOOST_CHECK_EQUAL((dist.min)(), BOOST_RANDOM_DIST0_MIN);
+ BOOST_CHECK_EQUAL((dist.max)(), BOOST_RANDOM_DIST0_MAX);
+ BOOST_RANDOM_DISTRIBUTION dist_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_CHECK_EQUAL((dist_one.min)(), BOOST_RANDOM_DIST1_MIN);
+ BOOST_CHECK_EQUAL((dist_one.max)(), BOOST_RANDOM_DIST1_MAX);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_CHECK_EQUAL((dist_two.min)(), BOOST_RANDOM_DIST2_MIN);
+ BOOST_CHECK_EQUAL((dist_two.max)(), BOOST_RANDOM_DIST2_MAX);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_RANDOM_DISTRIBUTION dist_three(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE, BOOST_RANDOM_ARG3_VALUE);
+ BOOST_CHECK_EQUAL((dist_three.min)(), BOOST_RANDOM_DIST3_MIN);
+ BOOST_CHECK_EQUAL((dist_three.max)(), BOOST_RANDOM_DIST3_MAX);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_comparison) {
+ BOOST_RANDOM_DISTRIBUTION dist;
+ BOOST_RANDOM_DISTRIBUTION dist_copy(dist);
+ BOOST_RANDOM_DISTRIBUTION dist_one(BOOST_RANDOM_ARG1_VALUE);
+ BOOST_RANDOM_DISTRIBUTION dist_one_copy(dist_one);
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_RANDOM_DISTRIBUTION dist_two(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+ BOOST_RANDOM_DISTRIBUTION dist_two_copy(dist_two);
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_RANDOM_DISTRIBUTION dist_three(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE, BOOST_RANDOM_ARG3_VALUE);
+ BOOST_RANDOM_DISTRIBUTION dist_three_copy(dist_three);
+#endif
+ BOOST_CHECK(dist == dist_copy);
+ BOOST_CHECK(!(dist != dist_copy));
+ BOOST_CHECK(dist_one == dist_one_copy);
+ BOOST_CHECK(!(dist_one != dist_one_copy));
+ BOOST_CHECK(dist != dist_one);
+ BOOST_CHECK(!(dist == dist_one));
+#ifdef BOOST_RANDOM_ARG2
+ BOOST_CHECK(dist_two == dist_two_copy);
+ BOOST_CHECK(!(dist_two != dist_two_copy));
+ BOOST_CHECK(dist != dist_two);
+ BOOST_CHECK(!(dist == dist_two));
+ BOOST_CHECK(dist_one != dist_two);
+ BOOST_CHECK(!(dist_one == dist_two));
+#endif
+#ifdef BOOST_RANDOM_ARG3
+ BOOST_CHECK(dist_three == dist_three_copy);
+ BOOST_CHECK(!(dist_three != dist_three_copy));
+ BOOST_CHECK(dist != dist_three);
+ BOOST_CHECK(!(dist == dist_three));
+ BOOST_CHECK(dist_one != dist_three);
+ BOOST_CHECK(!(dist_one == dist_three));
+ BOOST_CHECK(dist_two != dist_three);
+ BOOST_CHECK(!(dist_two == dist_three));
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_streaming) {
+#if defined(BOOST_RANDOM_ARG3)
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE, BOOST_RANDOM_ARG2_VALUE);
+#elif defined(BOOST_RANDOM_ARG2)
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE, BOOST_RANDOM_ARG2_VALUE);
+#else
+ BOOST_RANDOM_DISTRIBUTION dist(BOOST_RANDOM_ARG1_VALUE);
+#endif
+ std::stringstream stream;
+ stream << dist;
+ BOOST_RANDOM_DISTRIBUTION restored_dist;
+ stream >> restored_dist;
+ BOOST_CHECK_EQUAL(dist, restored_dist);
+}
+
+void use(BOOST_RANDOM_DISTRIBUTION::result_type) {}
+
+BOOST_AUTO_TEST_CASE(test_generation) {
+ boost::minstd_rand0 gen;
+ BOOST_RANDOM_DISTRIBUTION dist BOOST_RANDOM_TEST1_PARAMS;
+ BOOST_RANDOM_DISTRIBUTION dist_two BOOST_RANDOM_TEST2_PARAMS;
+ typedef BOOST_RANDOM_DISTRIBUTION::result_type result_type;
+ for(int i = 0; i < 10; ++i) {
+ result_type value = dist(gen);
+ use(value);
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two = dist_two(gen);
+ use(value_two);
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two, BOOST_RANDOM_TEST2_MAX);
+#endif
+ result_type value_param = dist_two(gen, dist.param());
+ use(value_param);
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value_param, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value_param, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two_param = dist(gen, dist_two.param());
+ use(value_two_param);
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two_param, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two_param, BOOST_RANDOM_TEST2_MAX);
+#endif
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_generation_float) {
+ boost::lagged_fibonacci607 gen;
+ BOOST_RANDOM_DISTRIBUTION dist BOOST_RANDOM_TEST1_PARAMS;
+ BOOST_RANDOM_DISTRIBUTION dist_two BOOST_RANDOM_TEST2_PARAMS;
+ typedef BOOST_RANDOM_DISTRIBUTION::result_type result_type;
+ for(int i = 0; i < 10; ++i) {
+ result_type value = dist(gen);
+ use(value);
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two = dist_two(gen);
+ use(value_two);
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two, BOOST_RANDOM_TEST2_MAX);
+#endif
+ result_type value_param = dist_two(gen, dist.param());
+ use(value_param);
+#ifdef BOOST_RANDOM_TEST1_MIN
+ BOOST_CHECK_GE(value_param, BOOST_RANDOM_TEST1_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST1_MAX
+ BOOST_CHECK_LE(value_param, BOOST_RANDOM_TEST1_MAX);
+#endif
+ result_type value_two_param = dist(gen, dist_two.param());
+ use(value_two_param);
+#ifdef BOOST_RANDOM_TEST2_MIN
+ BOOST_CHECK_GE(value_two_param, BOOST_RANDOM_TEST2_MIN);
+#endif
+#ifdef BOOST_RANDOM_TEST2_MAX
+ BOOST_CHECK_LE(value_two_param, BOOST_RANDOM_TEST2_MAX);
+#endif
+ }
+}
+
diff --git a/src/boost/libs/random/test/test_ecuyer1988.cpp b/src/boost/libs/random/test/test_ecuyer1988.cpp
new file mode 100644
index 000000000..81f06746f
--- /dev/null
+++ b/src/boost/libs/random/test/test_ecuyer1988.cpp
@@ -0,0 +1,24 @@
+/* test_ecuyer1988.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/additive_combine.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ecuyer1988
+
+#define BOOST_RANDOM_SEED_WORDS 2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 2060321752U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 1928563088U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 776923198U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x7AE0C087U, 0x948A8A31U, 0xBE5CCBA9U, 0x1316692CU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_exponential.cpp b/src/boost/libs/random/test/test_exponential.cpp
new file mode 100644
index 000000000..8a508401f
--- /dev/null
+++ b/src/boost/libs/random/test/test_exponential.cpp
@@ -0,0 +1,24 @@
+/* test_exponential.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/exponential_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/exponential.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::exponential_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME exponential
+#define BOOST_MATH_DISTRIBUTION boost::math::exponential
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME lambda
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.0001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_exponential_distribution.cpp b/src/boost/libs/random/test/test_exponential_distribution.cpp
new file mode 100644
index 000000000..169aab5fa
--- /dev/null
+++ b/src/boost/libs/random/test/test_exponential_distribution.cpp
@@ -0,0 +1,32 @@
+/* test_exponential_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/exponential_distribution.hpp>
+
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::exponential_distribution<>
+#define BOOST_RANDOM_ARG1 lambda
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (1000.0)
+#define BOOST_RANDOM_TEST2_MIN 0.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_extreme_value.cpp b/src/boost/libs/random/test/test_extreme_value.cpp
new file mode 100644
index 000000000..8df079c61
--- /dev/null
+++ b/src/boost/libs/random/test/test_extreme_value.cpp
@@ -0,0 +1,28 @@
+/* test_extreme_value.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/extreme_value_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/extreme_value.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::extreme_value_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME extreme_value
+#define BOOST_MATH_DISTRIBUTION boost::math::extreme_value
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME a
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME b
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_extreme_value_distribution.cpp b/src/boost/libs/random/test/test_extreme_value_distribution.cpp
new file mode 100644
index 000000000..fc9642c94
--- /dev/null
+++ b/src/boost/libs/random/test/test_extreme_value_distribution.cpp
@@ -0,0 +1,36 @@
+/* test_extreme_value_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/extreme_value_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::extreme_value_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS (-100.0)
+#define BOOST_RANDOM_TEST1_MAX 0
+
+#define BOOST_RANDOM_TEST2_PARAMS (100.0)
+#define BOOST_RANDOM_TEST2_MIN 0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_fisher_f.cpp b/src/boost/libs/random/test/test_fisher_f.cpp
new file mode 100644
index 000000000..24abb5a9f
--- /dev/null
+++ b/src/boost/libs/random/test/test_fisher_f.cpp
@@ -0,0 +1,28 @@
+/* test_fisher_f.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/fisher_f_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/fisher_f.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::fisher_f_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME fisher_f
+#define BOOST_MATH_DISTRIBUTION boost::math::fisher_f
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME m
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME n
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_fisher_f_distribution.cpp b/src/boost/libs/random/test/test_fisher_f_distribution.cpp
new file mode 100644
index 000000000..4eaa96c98
--- /dev/null
+++ b/src/boost/libs/random/test/test_fisher_f_distribution.cpp
@@ -0,0 +1,33 @@
+/* test_fisher_f_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/fisher_f_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::fisher_f_distribution<>
+#define BOOST_RANDOM_ARG1 m
+#define BOOST_RANDOM_ARG2 n
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0.0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0.0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0.0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS (1.0, 2.1)
+#define BOOST_RANDOM_TEST2_PARAMS (10.0, 10.0)
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_gamma.cpp b/src/boost/libs/random/test/test_gamma.cpp
new file mode 100644
index 000000000..cbbc351f1
--- /dev/null
+++ b/src/boost/libs/random/test/test_gamma.cpp
@@ -0,0 +1,28 @@
+/* test_gamma.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/gamma_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/gamma.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::gamma_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME gamma
+#define BOOST_MATH_DISTRIBUTION boost::math::gamma_distribution<>
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME alpha
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME beta
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_gamma_distribution.cpp b/src/boost/libs/random/test/test_gamma_distribution.cpp
new file mode 100644
index 000000000..2e9696f8b
--- /dev/null
+++ b/src/boost/libs/random/test/test_gamma_distribution.cpp
@@ -0,0 +1,37 @@
+/* test_gamma_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/gamma_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::gamma_distribution<>
+#define BOOST_RANDOM_ARG1 alpha
+#define BOOST_RANDOM_ARG2 beta
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 100.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (1.0, 1000000.0)
+#define BOOST_RANDOM_TEST2_MIN 100.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_generate_canonical.cpp b/src/boost/libs/random/test/test_generate_canonical.cpp
new file mode 100644
index 000000000..cc45f8a9e
--- /dev/null
+++ b/src/boost/libs/random/test/test_generate_canonical.cpp
@@ -0,0 +1,104 @@
+/* test_generate_canonical.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/generate_canonical.hpp>
+
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/mpl/vector.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+typedef boost::mpl::vector<
+ boost::random::minstd_rand,
+ boost::random::mt19937,
+ boost::random::lagged_fibonacci607
+> engines;
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_float, Engine, engines)
+{
+ Engine eng;
+ Engine expected;
+ for(int i = 0; i < 1000; ++i) {
+ float val = boost::random::generate_canonical<float, 64>(eng);
+ BOOST_CHECK_GE(val, 0);
+ BOOST_CHECK_LT(val, 1);
+ }
+ expected.discard(1000);
+ BOOST_CHECK_EQUAL(eng, expected);
+ for(int i = 0; i < 1000; ++i) {
+ float val = boost::random::generate_canonical<float, 12>(eng);
+ BOOST_CHECK_GE(val, 0);
+ BOOST_CHECK_LT(val, 1);
+ }
+ expected.discard(1000);
+ BOOST_CHECK_EQUAL(eng, expected);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_double, Engine, engines)
+{
+ Engine eng;
+ Engine expected;
+ for(int i = 0; i < 1000; ++i) {
+ double val = boost::random::generate_canonical<double, 64>(eng);
+ BOOST_CHECK_GE(val, 0);
+ BOOST_CHECK_LT(val, 1);
+ }
+ expected.discard(2000);
+ BOOST_CHECK_EQUAL(eng, expected);
+ for(int i = 0; i < 1000; ++i) {
+ double val = boost::random::generate_canonical<double, 12>(eng);
+ BOOST_CHECK_GE(val, 0);
+ BOOST_CHECK_LT(val, 1);
+ }
+ expected.discard(1000);
+ BOOST_CHECK_EQUAL(eng, expected);
+}
+
+BOOST_AUTO_TEST_CASE_TEMPLATE(test_long_double, Engine, engines)
+{
+ Engine eng;
+ Engine expected;
+ for(int i = 0; i < 1000; ++i) {
+ long double val = boost::random::generate_canonical<long double, 60>(eng);
+ BOOST_CHECK_GE(val, 0);
+ BOOST_CHECK_LT(val, 1);
+ }
+ expected.discard(2000);
+ BOOST_CHECK_EQUAL(eng, expected);
+ for(int i = 0; i < 1000; ++i) {
+ long double val = boost::random::generate_canonical<long double, 12>(eng);
+ BOOST_CHECK_GE(val, 0);
+ BOOST_CHECK_LT(val, 1);
+ }
+ expected.discard(1000);
+ BOOST_CHECK_EQUAL(eng, expected);
+}
+
+struct max_engine
+{
+ typedef boost::uint32_t result_type;
+ static result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
+ static result_type max BOOST_PREVENT_MACRO_SUBSTITUTION ()
+ { return ~boost::uint32_t(0); }
+ result_type operator()() { return (max)(); }
+};
+
+BOOST_AUTO_TEST_CASE(test_max)
+{
+ max_engine eng;
+ BOOST_CHECK_LT((boost::random::generate_canonical<float, 64>(eng)), 1);
+ BOOST_CHECK_LT((boost::random::generate_canonical<double, 64>(eng)), 1);
+ BOOST_CHECK_LT((boost::random::generate_canonical<long double, 64>(eng)), 1);
+}
diff --git a/src/boost/libs/random/test/test_generator.ipp b/src/boost/libs/random/test/test_generator.ipp
new file mode 100644
index 000000000..bd57bdd59
--- /dev/null
+++ b/src/boost/libs/random/test/test_generator.ipp
@@ -0,0 +1,279 @@
+/* test_generator.ipp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include "concepts.hpp"
+#include <boost/random/seed_seq.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using boost::random::test::RandomNumberEngine;
+BOOST_CONCEPT_ASSERT((RandomNumberEngine< BOOST_RANDOM_URNG >));
+
+typedef BOOST_RANDOM_URNG::result_type result_type;
+typedef boost::random::detail::seed_type<result_type>::type seed_type;
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4244)
+#endif
+
+#ifndef BOOST_RANDOM_DISCARD_COUNT1
+#define BOOST_RANDOM_DISCARD_COUNT1 9307
+#endif
+
+template<class Converted, class URNG, class T>
+void test_seed_conversion(URNG & urng, const T & t)
+{
+ Converted c = static_cast<Converted>(t);
+ if(static_cast<T>(c) == t) {
+ URNG urng2(c);
+ std::ostringstream msg;
+ msg << "Testing seed: type " << typeid(Converted).name() << ", value " << c;
+ BOOST_CHECK_MESSAGE(urng == urng2, msg.str());
+ urng2.seed(c);
+ BOOST_CHECK_MESSAGE(urng == urng2, msg.str());
+ }
+}
+
+#ifdef BOOST_MSVC
+#pragma warning(pop)
+#endif
+
+void test_seed(seed_type value)
+{
+ BOOST_RANDOM_URNG urng(value);
+
+ // integral types
+ test_seed_conversion<char>(urng, value);
+ test_seed_conversion<signed char>(urng, value);
+ test_seed_conversion<unsigned char>(urng, value);
+ test_seed_conversion<short>(urng, value);
+ test_seed_conversion<unsigned short>(urng, value);
+ test_seed_conversion<int>(urng, value);
+ test_seed_conversion<unsigned int>(urng, value);
+ test_seed_conversion<long>(urng, value);
+ test_seed_conversion<unsigned long>(urng, value);
+#if !defined(BOOST_NO_INT64_T)
+ test_seed_conversion<boost::int64_t>(urng, value);
+ test_seed_conversion<boost::uint64_t>(urng, value);
+#endif
+
+ // floating point types
+ test_seed_conversion<float>(urng, value);
+ test_seed_conversion<double>(urng, value);
+ test_seed_conversion<long double>(urng, value);
+}
+
+BOOST_AUTO_TEST_CASE(test_default_seed)
+{
+ BOOST_RANDOM_URNG urng;
+ BOOST_RANDOM_URNG urng2;
+ urng2();
+ BOOST_CHECK_NE(urng, urng2);
+ urng2.seed();
+ BOOST_CHECK_EQUAL(urng, urng2);
+}
+
+BOOST_AUTO_TEST_CASE(test_arithmetic_seed)
+{
+ test_seed(static_cast<seed_type>(0));
+ test_seed(static_cast<seed_type>(127));
+ test_seed(static_cast<seed_type>(539157235));
+ test_seed(static_cast<seed_type>(~0u));
+}
+
+BOOST_AUTO_TEST_CASE(test_iterator_seed)
+{
+ const std::vector<int> v((std::max)(std::size_t(9999u), sizeof(BOOST_RANDOM_URNG) / 4), 0x41);
+ std::vector<int>::const_iterator it = v.begin();
+ std::vector<int>::const_iterator it_end = v.end();
+ BOOST_RANDOM_URNG urng(it, it_end);
+ BOOST_CHECK(it != v.begin());
+ std::iterator_traits<std::vector<int>::const_iterator>::difference_type n_words = (it - v.begin());
+ BOOST_CHECK_GT(n_words, 0);
+ BOOST_CHECK_EQUAL(n_words, BOOST_RANDOM_SEED_WORDS);
+
+ it = v.begin();
+ BOOST_RANDOM_URNG urng2;
+ urng2.seed(it, it_end);
+ std::iterator_traits<std::vector<int>::const_iterator>::difference_type n_words2 = (it - v.begin());
+ BOOST_CHECK_EQUAL(n_words, n_words2);
+ BOOST_CHECK_EQUAL(urng, urng2);
+
+ it = v.end();
+ BOOST_CHECK_THROW(BOOST_RANDOM_URNG(it, it_end), std::invalid_argument);
+ BOOST_CHECK_THROW(urng.seed(it, it_end), std::invalid_argument);
+
+ if(n_words > 1) {
+ it = v.end();
+ --it;
+ BOOST_CHECK_THROW(BOOST_RANDOM_URNG(it, it_end), std::invalid_argument);
+ it = v.end();
+ --it;
+ BOOST_CHECK_THROW(urng.seed(it, it_end), std::invalid_argument);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_seed_seq_seed)
+{
+ boost::random::seed_seq q;
+ BOOST_RANDOM_URNG urng(q);
+ BOOST_RANDOM_URNG urng2;
+ BOOST_CHECK_NE(urng, urng2);
+ urng2.seed(q);
+ BOOST_CHECK_EQUAL(urng, urng2);
+}
+
+template<class CharT>
+void do_test_streaming(const BOOST_RANDOM_URNG& urng)
+{
+ BOOST_RANDOM_URNG urng2;
+ std::basic_ostringstream<CharT> output;
+ output << urng;
+ BOOST_CHECK_NE(urng, urng2);
+ // restore old state
+ std::basic_istringstream<CharT> input(output.str());
+ input >> urng2;
+ BOOST_CHECK_EQUAL(urng, urng2);
+}
+
+BOOST_AUTO_TEST_CASE(test_streaming)
+{
+ BOOST_RANDOM_URNG urng;
+ urng.discard(9307);
+ do_test_streaming<char>(urng);
+#if !defined(BOOST_NO_STD_WSTREAMBUF) && !defined(BOOST_NO_STD_WSTRING)
+ do_test_streaming<wchar_t>(urng);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_discard)
+{
+ BOOST_RANDOM_URNG urng;
+ BOOST_RANDOM_URNG urng2;
+ BOOST_CHECK_EQUAL(urng, urng2);
+ for(int i = 0; i < BOOST_RANDOM_DISCARD_COUNT1; ++i)
+ urng();
+ BOOST_CHECK_NE(urng, urng2);
+ urng2.discard(BOOST_RANDOM_DISCARD_COUNT1);
+ BOOST_CHECK_EQUAL(urng, urng2);
+}
+
+#ifdef BOOST_RANDOM_DISCARD_COUNT2
+BOOST_AUTO_TEST_CASE(test_discard2)
+{
+ BOOST_RANDOM_URNG urng;
+ BOOST_RANDOM_URNG urng2;
+ BOOST_CHECK_EQUAL(urng, urng2);
+ for(int i = 0; i < BOOST_RANDOM_DISCARD_COUNT2; ++i)
+ urng();
+ BOOST_CHECK_NE(urng, urng2);
+ urng2.discard(BOOST_RANDOM_DISCARD_COUNT2);
+ BOOST_CHECK_EQUAL(urng, urng2);
+}
+#endif
+
+#ifdef BOOST_RANDOM_DISCARD_MAX
+BOOST_AUTO_TEST_CASE(test_discard_max)
+{
+ boost::uintmax_t val = (std::numeric_limits<boost::uintmax_t>::max)();
+ boost::uintmax_t half = val / 2;
+ BOOST_RANDOM_URNG urng;
+ BOOST_RANDOM_URNG urng2;
+ urng.discard(half);
+ urng.discard(half);
+ urng.discard(val - 2*half);
+ urng2.discard(val);
+ BOOST_CHECK_EQUAL(urng, urng2);
+}
+#endif
+
+BOOST_AUTO_TEST_CASE(test_copy)
+{
+ BOOST_RANDOM_URNG urng;
+ urng.discard(9307);
+ {
+ BOOST_RANDOM_URNG urng2 = urng;
+ BOOST_CHECK_EQUAL(urng, urng2);
+ }
+ {
+ BOOST_RANDOM_URNG urng2(urng);
+ BOOST_CHECK_EQUAL(urng, urng2);
+ }
+ {
+ BOOST_RANDOM_URNG urng2;
+ urng2 = urng;
+ BOOST_CHECK_EQUAL(urng, urng2);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_min_max)
+{
+ BOOST_RANDOM_URNG urng;
+ for(int i = 0; i < 10000; ++i) {
+ result_type value = urng();
+ BOOST_CHECK_GE(value, (BOOST_RANDOM_URNG::min)());
+ BOOST_CHECK_LE(value, (BOOST_RANDOM_URNG::max)());
+ }
+}
+
+BOOST_AUTO_TEST_CASE(test_comparison)
+{
+ BOOST_RANDOM_URNG urng;
+ BOOST_RANDOM_URNG urng2;
+ BOOST_CHECK(urng == urng2);
+ BOOST_CHECK(!(urng != urng2));
+ urng();
+ BOOST_CHECK(urng != urng2);
+ BOOST_CHECK(!(urng == urng2));
+}
+
+BOOST_AUTO_TEST_CASE(validate)
+{
+ BOOST_RANDOM_URNG urng;
+ for(int i = 0; i < 9999; ++i) {
+ urng();
+ }
+ BOOST_CHECK_EQUAL(urng(), BOOST_RANDOM_VALIDATION_VALUE);
+}
+
+BOOST_AUTO_TEST_CASE(validate_seed_seq)
+{
+ boost::random::seed_seq seed;
+ BOOST_RANDOM_URNG urng(seed);
+ for(int i = 0; i < 9999; ++i) {
+ urng();
+ }
+ BOOST_CHECK_EQUAL(urng(), BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE);
+}
+
+BOOST_AUTO_TEST_CASE(validate_iter)
+{
+ const std::vector<int> v((std::max)(std::size_t(9999u), sizeof(BOOST_RANDOM_URNG) / 4), 0x41);
+ std::vector<int>::const_iterator it = v.begin();
+ std::vector<int>::const_iterator it_end = v.end();
+ BOOST_RANDOM_URNG urng(it, it_end);
+ for(int i = 0; i < 9999; ++i) {
+ urng();
+ }
+ BOOST_CHECK_EQUAL(urng(), BOOST_RANDOM_ITERATOR_VALIDATION_VALUE);
+}
+
+BOOST_AUTO_TEST_CASE(test_generate)
+{
+ BOOST_RANDOM_URNG urng;
+ boost::uint32_t expected[] = BOOST_RANDOM_GENERATE_VALUES;
+ static const std::size_t N = sizeof(expected)/sizeof(expected[0]);
+ boost::uint32_t actual[N];
+ urng.generate(&actual[0], &actual[0] + N);
+ BOOST_CHECK_EQUAL_COLLECTIONS(actual, actual + N, expected, expected + N);
+}
diff --git a/src/boost/libs/random/test/test_geometric.cpp b/src/boost/libs/random/test/test_geometric.cpp
new file mode 100644
index 000000000..bd61dd44c
--- /dev/null
+++ b/src/boost/libs/random/test/test_geometric.cpp
@@ -0,0 +1,26 @@
+/* test_geometric.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/geometric_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/geometric.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::geometric_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME geometric
+#define BOOST_MATH_DISTRIBUTION boost::math::geometric
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME p
+#define BOOST_RANDOM_ARG1_DEFAULT 0.5
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.0001, 0.9999)
+#define BOOST_RANDOM_DISTRIBUTION_MAX boost::numeric_cast<int>(-5 / std::log(1-p))
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_geometric_distribution.cpp b/src/boost/libs/random/test/test_geometric_distribution.cpp
new file mode 100644
index 000000000..bb54d0259
--- /dev/null
+++ b/src/boost/libs/random/test/test_geometric_distribution.cpp
@@ -0,0 +1,31 @@
+/* test_geometric_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/geometric_distribution.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::geometric_distribution<>
+#define BOOST_RANDOM_ARG1 p
+#define BOOST_RANDOM_ARG1_DEFAULT 0.5
+#define BOOST_RANDOM_ARG1_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<int>::max)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<int>::max)()
+
+#define BOOST_RANDOM_TEST1_PARAMS (0.9999)
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 0
+
+#define BOOST_RANDOM_TEST2_PARAMS (0.0001)
+#define BOOST_RANDOM_TEST2_MIN 1
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_hellekalek1995.cpp b/src/boost/libs/random/test/test_hellekalek1995.cpp
new file mode 100644
index 000000000..cc69ebd28
--- /dev/null
+++ b/src/boost/libs/random/test/test_hellekalek1995.cpp
@@ -0,0 +1,24 @@
+/* test_mt19937.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/inversive_congruential.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::hellekalek1995
+
+#define BOOST_RANDOM_SEED_WORDS 1
+
+#define BOOST_RANDOM_VALIDATION_VALUE 1187812169U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 1912573642U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 618743552U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x5642A47BU, 0x1F6987E8U, 0xD35860E7U, 0xC8C661ABU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_hyperexponential.cpp b/src/boost/libs/random/test/test_hyperexponential.cpp
new file mode 100644
index 000000000..9f3cf8285
--- /dev/null
+++ b/src/boost/libs/random/test/test_hyperexponential.cpp
@@ -0,0 +1,225 @@
+/* test_hyperexponential.cpp
+ *
+ * Copyright Marco Guazzone 2014
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * \author Marco Guazzone (marco.guazzone@gmail.com)
+ *
+ */
+
+#include <boost/exception/diagnostic_information.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/math/distributions/hyperexponential.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <boost/random/hyperexponential_distribution.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/range/numeric.hpp>
+#include <cstring>
+#include <iostream>
+#include <numeric>
+#include <vector>
+
+#include "statistic_tests.hpp"
+
+
+// This test unit is similar to the one in "test_real_distribution.ipp", which
+// has been changed for the hyperexponential distribution.
+// We cannot directly use the original test suite since it doesn't work for
+// distributions with vector parameters.
+// Also, this implementation has been inspired by the test unit for the
+// discrete_distribution class.
+
+
+#ifndef BOOST_RANDOM_P_CUTOFF
+# define BOOST_RANDOM_P_CUTOFF 0.99
+#endif
+
+#define BOOST_RANDOM_HYPEREXP_NUM_PHASES_MIN 1
+#define BOOST_RANDOM_HYPEREXP_NUM_PHASES_MAX 3
+#define BOOST_RANDOM_HYPEREXP_PROBABILITY_MIN 0.01
+#define BOOST_RANDOM_HYPEREXP_PROBABILITY_MAX 1.0
+#define BOOST_RANDOM_HYPEREXP_RATE_MIN 0.0001
+#define BOOST_RANDOM_HYPEREXP_RATE_MAX 1000.0
+#define BOOST_RANDOM_HYPEREXP_NUM_TRIALS 1000000ll
+
+
+namespace /*<unnamed>*/ { namespace detail {
+
+template <typename T>
+std::vector<T>& normalize(std::vector<T>& v)
+{
+ if (v.size() == 0)
+ {
+ return v;
+ }
+
+ const T sum = std::accumulate(v.begin(), v.end(), static_cast<T>(0));
+ T final_sum = 0;
+
+ const typename std::vector<T>::iterator end = --v.end();
+ for (typename std::vector<T>::iterator it = v.begin();
+ it != end;
+ ++it)
+ {
+ *it /= sum;
+ }
+ *end = 1 - final_sum; // avoids round off errors, ensures the probs really do sum to 1.
+
+ return v;
+}
+
+template <typename T>
+std::vector<T> normalize_copy(std::vector<T> const& v)
+{
+ std::vector<T> vv(v);
+
+ return normalize(vv);
+}
+
+template <typename T, typename DistT, typename EngineT>
+std::vector<T> make_random_vector(std::size_t n, DistT const& dist, EngineT& eng)
+{
+ std::vector<T> res(n);
+
+ for (std::size_t i = 0; i < n; ++i)
+ {
+ res[i] = dist(eng);
+ }
+
+ return res;
+}
+
+}} // Namespace <unnamed>::detail
+
+
+bool do_test(std::vector<double> const& probabilities,
+ std::vector<double> const& rates,
+ long long max,
+ boost::mt19937& gen)
+{
+ std::cout << "running hyperexponential(probabilities,rates) " << max << " times: " << std::flush;
+
+ boost::math::hyperexponential_distribution<> expected(probabilities, rates);
+
+ boost::random::hyperexponential_distribution<> dist(probabilities, rates);
+
+ kolmogorov_experiment test(boost::numeric_cast<int>(max));
+ boost::variate_generator<boost::mt19937&, boost::random::hyperexponential_distribution<> > vgen(gen, dist);
+
+ const double prob = test.probability(test.run(vgen, expected));
+
+ const bool result = prob < BOOST_RANDOM_P_CUTOFF;
+ const char* err = result? "" : "*";
+ std::cout << std::setprecision(17) << prob << err << std::endl;
+
+ std::cout << std::setprecision(6);
+
+ return result;
+}
+
+bool do_tests(int repeat, int max_num_phases, double max_rate, long long trials)
+{
+ boost::mt19937 gen;
+ boost::random::uniform_int_distribution<> num_phases_dist(BOOST_RANDOM_HYPEREXP_NUM_PHASES_MIN, max_num_phases);
+
+ int errors = 0;
+ for (int i = 0; i < repeat; ++i)
+ {
+ const int num_phases = num_phases_dist(gen);
+ boost::random::uniform_real_distribution<> prob_dist(BOOST_RANDOM_HYPEREXP_PROBABILITY_MIN, BOOST_RANDOM_HYPEREXP_PROBABILITY_MAX);
+ boost::random::uniform_real_distribution<> rate_dist(BOOST_RANDOM_HYPEREXP_RATE_MIN, max_rate);
+
+ const std::vector<double> probabilities = detail::normalize_copy(detail::make_random_vector<double>(num_phases, prob_dist, gen));
+ const std::vector<double> rates = detail::make_random_vector<double>(num_phases, rate_dist, gen);
+
+ if (!do_test(probabilities, rates, trials, gen))
+ {
+ ++errors;
+ }
+ }
+ if (errors != 0)
+ {
+ std::cout << "*** " << errors << " errors detected ***" << std::endl;
+ }
+
+ return errors == 0;
+}
+
+int usage()
+{
+ std::cerr << "Usage: test_hyperexponential"
+ " -r <repeat>"
+ " -num_phases"
+ " <max num_phases>"
+ " -rate"
+ " <max rate>"
+ " -t <trials>" << std::endl;
+ return 2;
+}
+
+template<class T>
+bool handle_option(int& argc, char**& argv, const char* opt, T& value)
+{
+ if (std::strcmp(argv[0], opt) == 0 && argc > 1)
+ {
+ --argc;
+ ++argv;
+ value = boost::lexical_cast<T>(argv[0]);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
+int main(int argc, char** argv)
+{
+ int repeat = 1;
+ int max_num_phases = BOOST_RANDOM_HYPEREXP_NUM_PHASES_MAX;
+ double max_rate = BOOST_RANDOM_HYPEREXP_RATE_MAX;
+ long long trials = BOOST_RANDOM_HYPEREXP_NUM_TRIALS;
+
+ if (argc > 0)
+ {
+ --argc;
+ ++argv;
+ }
+ while(argc > 0)
+ {
+ if (argv[0][0] != '-')
+ {
+ return usage();
+ }
+ else if (!handle_option(argc, argv, "-r", repeat)
+ && !handle_option(argc, argv, "-num_phases", max_num_phases)
+ && !handle_option(argc, argv, "-rate", max_rate)
+ && !handle_option(argc, argv, "-t", trials))
+ {
+ return usage();
+ }
+ --argc;
+ ++argv;
+ }
+
+ try
+ {
+ if (do_tests(repeat, max_num_phases, max_rate, trials))
+ {
+ return 0;
+ }
+ else
+ {
+ return EXIT_FAILURE;
+ }
+ }
+ catch(...)
+ {
+ std::cerr << boost::current_exception_diagnostic_information() << std::endl;
+ return EXIT_FAILURE;
+ }
+}
diff --git a/src/boost/libs/random/test/test_hyperexponential_distribution.cpp b/src/boost/libs/random/test/test_hyperexponential_distribution.cpp
new file mode 100644
index 000000000..81c0b6987
--- /dev/null
+++ b/src/boost/libs/random/test/test_hyperexponential_distribution.cpp
@@ -0,0 +1,467 @@
+/* test_hyperexponential_distribution.ipp
+ *
+ * Copyright 2014 Marco Guazzone (marco.guazzone@gmail.com)
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ */
+
+
+#include <boost/math/tools/precision.hpp>
+#include <boost/random/hyperexponential_distribution.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
+#include <boost/assign/list_of.hpp>
+#include <limits>
+#include <sstream>
+#include <vector>
+
+#include "concepts.hpp"
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+
+#define BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(T, actual, expected, tol)\
+ do { \
+ std::vector<T> x = (actual); \
+ std::vector<T> y = (expected); \
+ BOOST_CHECK_EQUAL( x.size(), y.size() ); \
+ const std::size_t n = x.size(); \
+ for (std::size_t i = 0; i < n; ++i) \
+ { \
+ BOOST_CHECK_CLOSE( x[i], y[i], tol ); \
+ } \
+ } while(false)
+
+
+
+namespace /*<unnamed>*/ { namespace detail {
+
+template <typename RealT>
+RealT make_tolerance()
+{
+ // Tolerance is 100eps expressed as a percentage (as required by Boost.Build):
+ return boost::math::tools::epsilon<RealT>() * 100 * 100;
+}
+
+}} // Namespace <unnamed>::detail
+
+
+BOOST_CONCEPT_ASSERT((boost::random::test::RandomNumberDistribution< boost::random::hyperexponential_distribution<> >));
+
+BOOST_AUTO_TEST_CASE( test_constructors )
+{
+ const double tol = detail::make_tolerance<double>();
+
+ // Test default ctor
+ boost::random::hyperexponential_distribution<> dist;
+ BOOST_CHECK_EQUAL(dist.num_phases(), 1u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist.probabilities(), boost::assign::list_of(1.0), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist.rates(), boost::assign::list_of(1.0), tol);
+
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ // Test ctor from initializer_list with probabilities and rates
+ boost::random::hyperexponential_distribution<> dist_il_p_r = {{1, 2, 3, 4 }, {1, 2, 3, 4}};
+ BOOST_CHECK_EQUAL(dist_il_p_r.num_phases(), 4u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_il_p_r.probabilities(), boost::assign::list_of(.1)(.2)(.3)(.4), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_il_p_r.rates(), boost::assign::list_of(1.)(2.)(3.)(4.), tol);
+
+ // Test ctor from initializer_list with rates
+ boost::random::hyperexponential_distribution<> dist_il_r = {{1, 2, 3, 4}};
+ BOOST_CHECK_EQUAL(dist_il_r.num_phases(), 4u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_il_r.probabilities(), boost::assign::list_of(.25)(.25)(.25)(.25), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_il_r.rates(), boost::assign::list_of(1.)(2.)(3.)(4.), tol);
+#endif
+
+ const std::vector<double> probs = boost::assign::list_of(0.1)(0.2)(0.3)(0.4);
+ const std::vector<double> rates = boost::assign::list_of(1.0)(2.0)(3.0)(4.0);
+
+ // Test ctor from range
+ boost::random::hyperexponential_distribution<> dist_r(probs, rates);
+ BOOST_CHECK_EQUAL(dist_r.num_phases(), 4u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r.probabilities(), probs, tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r.rates(), rates, tol);
+
+ // Test ctor from iterators
+ boost::random::hyperexponential_distribution<> dist_it(probs.begin(), probs.end(), rates.begin(), rates.end());
+ BOOST_CHECK_EQUAL(dist_it.num_phases(), 4u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_it.probabilities(), probs, tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_it.rates(), rates, tol);
+
+ // Test ctor from rate iterators
+ boost::random::hyperexponential_distribution<> dist_r_it(rates.begin(), rates.end());
+ BOOST_CHECK_EQUAL(dist_r_it.num_phases(), 4u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r_it.probabilities(), boost::assign::list_of(.25)(.25)(.25)(.25), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r_it.rates(), rates, tol);
+
+ // Test ctor from rate iterators #2
+ {
+ const double rates2[] = {1.0,2.0,3.0,4.0};
+ boost::random::hyperexponential_distribution<> dist_r_it(rates2, rates2+4);
+ BOOST_CHECK_EQUAL(dist_r_it.num_phases(), 4u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r_it.probabilities(), boost::assign::list_of(.25)(.25)(.25)(.25), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r_it.rates(), std::vector<double>(rates2, rates2+4), tol);
+ }
+
+ // Test ctor from rate range
+ boost::random::hyperexponential_distribution<> dist_r_r(rates);
+ BOOST_CHECK_EQUAL(dist_r_r.num_phases(), 4u);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r_r.probabilities(), boost::assign::list_of(.25)(.25)(.25)(.25), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist_r_r.rates(), rates, tol);
+
+ // Test copy ctor
+ boost::random::hyperexponential_distribution<> cp(dist);
+ BOOST_CHECK_EQUAL(cp, dist);
+ boost::random::hyperexponential_distribution<> cp_r(dist_r);
+ BOOST_CHECK_EQUAL(cp_r, dist_r);
+}
+
+BOOST_AUTO_TEST_CASE( test_param )
+{
+ const double tol = detail::make_tolerance<double>();
+
+ const std::vector<double> probs = boost::assign::list_of(0.1)(0.2)(0.3)(0.4);
+ const std::vector<double> rates = boost::assign::list_of(1.0)(2.0)(3.0)(4.0);
+
+ // Test param getter
+ boost::random::hyperexponential_distribution<> dist(probs, rates);
+ boost::random::hyperexponential_distribution<>::param_type param = dist.param();
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist.probabilities(), param.probabilities(), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist.rates(), param.rates(), tol);
+
+ // Test ctor from param
+ boost::random::hyperexponential_distribution<> cp1(param);
+ BOOST_CHECK_EQUAL(cp1, dist);
+
+ // Test param setter
+ boost::random::hyperexponential_distribution<> cp2;
+ cp2.param(param);
+ BOOST_CHECK_EQUAL(cp2, dist);
+
+ // Test param constructors & operators
+ boost::random::hyperexponential_distribution<>::param_type param_copy = param;
+ BOOST_CHECK_EQUAL(param, param_copy);
+ BOOST_CHECK(param == param_copy);
+ BOOST_CHECK(!(param != param_copy));
+ boost::random::hyperexponential_distribution<>::param_type param_default;
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_default.probabilities(), boost::assign::list_of(1.0), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_default.rates(), boost::assign::list_of(1.0), tol);
+ BOOST_CHECK(param != param_default);
+ BOOST_CHECK(!(param == param_default));
+#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST) && !defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
+ boost::random::hyperexponential_distribution<>::param_type param_il = {{1, 2, 3, 4 }, {1, 2, 3, 4}};
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_il.probabilities(), boost::assign::list_of(.1)(.2)(.3)(.4), tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_il.rates(), boost::assign::list_of(1.)(2.)(3.)(4.), tol);
+#endif
+ boost::random::hyperexponential_distribution<>::param_type param_r(probs, rates);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_r.probabilities(), probs, tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_r.rates(), rates, tol);
+
+ boost::random::hyperexponential_distribution<>::param_type param_it(probs.begin(), probs.end(), rates.begin(), rates.end());
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_it.probabilities(), probs, tol);
+ BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, param_it.rates(), rates, tol);
+}
+
+BOOST_AUTO_TEST_CASE( test_min_max )
+{
+ //const double tol = detail::make_tolerance<double>();
+
+ const std::vector<double> probs = boost::assign::list_of(0.1)(0.2)(0.3)(0.4);
+ const std::vector<double> rates = boost::assign::list_of(1.0)(2.0)(3.0)(4.0);
+
+ boost::random::hyperexponential_distribution<> dist;
+ BOOST_CHECK_EQUAL((dist.min)(), 0);
+ BOOST_CHECK_EQUAL((dist.max)(), (std::numeric_limits<double>::infinity)());
+
+ boost::random::hyperexponential_distribution<> dist_r(probs, rates);
+ BOOST_CHECK_EQUAL((dist_r.min)(), 0);
+ BOOST_CHECK_EQUAL((dist_r.max)(), (std::numeric_limits<double>::infinity)());
+}
+
+BOOST_AUTO_TEST_CASE(test_comparison)
+{
+ //const double tol = detail::make_tolerance<double>();
+
+ const std::vector<double> probs = boost::assign::list_of(0.1)(0.2)(0.3)(0.4);
+ const std::vector<double> rates = boost::assign::list_of(1.0)(2.0)(3.0)(4.0);
+
+ boost::random::hyperexponential_distribution<> dist;
+ boost::random::hyperexponential_distribution<> dist_copy(dist);
+
+ boost::random::hyperexponential_distribution<> dist_r(probs, rates);
+ boost::random::hyperexponential_distribution<> dist_r_copy(dist_r);
+
+ BOOST_CHECK(dist == dist_copy);
+ BOOST_CHECK(!(dist != dist_copy));
+ BOOST_CHECK(dist_r == dist_r_copy);
+ BOOST_CHECK(!(dist_r != dist_r_copy));
+ BOOST_CHECK(dist != dist_r);
+ BOOST_CHECK(!(dist == dist_r));
+}
+
+BOOST_AUTO_TEST_CASE( test_streaming )
+{
+ //const double tol = detail::make_tolerance<double>();
+
+ const std::vector<double> probs = boost::assign::list_of(0.1)(0.2)(0.3)(0.4);
+ const std::vector<double> rates = boost::assign::list_of(1.0)(2.0)(3.0)(4.0);
+ const std::vector<double> empty_vector;
+
+ // Test the reading of param_type
+
+ // - Test with valid input
+ {
+ boost::random::hyperexponential_distribution<>::param_type parm(probs, rates);
+ std::stringstream ss;
+ ss << parm;
+ boost::random::hyperexponential_distribution<>::param_type restored_parm;
+ ss >> restored_parm;
+ BOOST_CHECK_EQUAL(parm, restored_parm);
+ }
+
+ // - Test with an empty probability vector and ios_base exceptions disabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, rates);
+ boost::random::hyperexponential_distribution<>::param_type param;
+ ss >> param;
+ boost::random::hyperexponential_distribution<>::param_type check_param(std::vector<double>(rates.size(), 1), rates);
+ BOOST_CHECK_EQUAL(param, check_param);
+ }
+
+ // - Test with an empty rate vector and ios_base exceptions disabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, probs);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<>::param_type param;
+ ss >> param;
+ boost::random::hyperexponential_distribution<>::param_type check_param(probs, std::vector<double>(probs.size(), 1));
+ BOOST_CHECK_EQUAL(param, check_param);
+ }
+
+ // - Test with an empty probability and rate vectors and ios_base exceptions disabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<>::param_type param;
+ ss >> param;
+ boost::random::hyperexponential_distribution<>::param_type check_param;
+ BOOST_CHECK_EQUAL(param, check_param);
+ }
+
+ // - Test with an empty probability vector and ios_base exceptions enabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, rates);
+ boost::random::hyperexponential_distribution<>::param_type param;
+ ss.exceptions(std::ios_base::failbit);
+ ss >> param;
+ boost::random::hyperexponential_distribution<>::param_type check_param(std::vector<double>(rates.size(), 1), rates);
+ BOOST_CHECK_EQUAL(param, check_param);
+ }
+
+ // - Test with an empty rate vector and ios_base exceptions enabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, probs);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<>::param_type param;
+ ss.exceptions(std::ios_base::failbit);
+ ss >> param;
+ boost::random::hyperexponential_distribution<>::param_type check_param(probs, std::vector<double>(probs.size(), 1));
+ BOOST_CHECK_EQUAL(param, check_param);
+ }
+
+ // - Test with an empty probability and rate vectors and ios_base exceptions enabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<>::param_type param;
+ ss.exceptions(std::ios_base::failbit);
+ ss >> param;
+ boost::random::hyperexponential_distribution<>::param_type check_param;
+ BOOST_CHECK_EQUAL(param, check_param);
+ }
+
+ // The the reading of hyperexponential_distribution
+
+ // - Test with valid input
+ {
+ boost::random::hyperexponential_distribution<> dist(probs, rates);
+ std::stringstream ss;
+ ss << dist;
+ boost::random::hyperexponential_distribution<> restored_dist;
+ ss >> restored_dist;
+ BOOST_CHECK_EQUAL(dist, restored_dist);
+ }
+
+ // - Test with an empty probability vector and ios_base exceptions disabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, rates);
+ boost::random::hyperexponential_distribution<> dist;
+ ss >> dist;
+ boost::random::hyperexponential_distribution<> check_dist(std::vector<double>(rates.size(), 1), rates);
+ BOOST_CHECK_EQUAL(dist, check_dist);
+ }
+
+ // - Test with an empty rate vector and ios_base exceptions disabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, probs);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<> dist;
+ ss >> dist;
+ boost::random::hyperexponential_distribution<> check_dist(probs, std::vector<double>(probs.size(), 1));
+ BOOST_CHECK_EQUAL(dist, check_dist);
+ }
+
+ // - Test with an empty probability and rate vectors and ios_base exceptions disabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<> dist;
+ ss >> dist;
+ boost::random::hyperexponential_distribution<> check_dist;
+ BOOST_CHECK_EQUAL(dist, check_dist);
+ }
+
+ // - Test with an empty probability vector and ios_base exceptions enabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, rates);
+ boost::random::hyperexponential_distribution<> dist;
+ ss.exceptions(std::ios_base::failbit);
+ ss >> dist;
+ boost::random::hyperexponential_distribution<> check_dist(std::vector<double>(rates.size(), 1), rates);
+ BOOST_CHECK_EQUAL(dist, check_dist);
+ }
+
+ // - Test with an empty rate vector and ios_base exceptions enabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, probs);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<> dist;
+ ss.exceptions(std::ios_base::failbit);
+ ss >> dist;
+ boost::random::hyperexponential_distribution<> check_dist(probs, std::vector<double>(probs.size(), 1));
+ BOOST_CHECK_EQUAL(dist, check_dist);
+ }
+
+ // - Test with an empty probability and rate vectors and ios_base exceptions enabled
+ {
+ std::stringstream ss;
+ boost::random::detail::print_vector(ss, empty_vector);
+ ss << ' ';
+ boost::random::detail::print_vector(ss, empty_vector);
+ boost::random::hyperexponential_distribution<> dist;
+ ss.exceptions(std::ios_base::failbit);
+ ss >> dist;
+ boost::random::hyperexponential_distribution<> check_dist;
+ BOOST_CHECK_EQUAL(dist, check_dist);
+ }
+}
+
+//NOTE: test case commented since normalization check in \c hyperexp_detail::check_probabilities has been currently commented
+//BOOST_AUTO_TEST_CASE( test_normalization )
+//{
+// const double tol = detail::make_tolerance<double>();
+//
+// const std::vector<double> probs = boost::assign::list_of(1023.0)(1.0);
+// const std::vector<double> rates = boost::assign::list_of(1023.0)(1.0);
+// const std::vector<double> norm_probs = boost::assign::list_of(1023.0/1024.0)(1.0/1024.0);
+//
+// boost::random::hyperexponential_distribution<> dist(probs, rates);
+// BOOST_CHECK( boost::random::hyperexp_detail::check_params(dist.probabilities(), dist.rates()) );
+// BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist.probabilities(), norm_probs, tol);
+//
+// const std::vector<double> probs2 = boost::assign::list_of(1001.0)(1.0);
+// const std::vector<double> rates2 = boost::assign::list_of(1001.0)(1.0);
+// const std::vector<double> norm_probs2 = boost::assign::list_of(1001.0/1002.0)(1.0/1002.0);
+//
+// boost::random::hyperexponential_distribution<> dist2(probs2, rates2);
+// BOOST_CHECK( boost::random::hyperexp_detail::check_params(dist2.probabilities(), dist2.rates()) );
+// BOOST_RANDOM_HYPEREXP_CHECK_CLOSE_COLLECTIONS(double, dist2.probabilities(), norm_probs2, tol);
+//}
+
+void use(boost::random::hyperexponential_distribution<>::result_type) {}
+
+BOOST_AUTO_TEST_CASE(test_generation)
+{
+ //const double tol = detail::make_tolerance<double>();
+
+ const std::vector<double> probs = boost::assign::list_of(0.1)(0.2)(0.3)(0.4);
+ const std::vector<double> rates = boost::assign::list_of(1.0)(2.0)(3.0)(4.0);
+
+ boost::minstd_rand0 gen;
+
+ boost::random::hyperexponential_distribution<> dist;
+ boost::random::hyperexponential_distribution<> dist_r(probs, rates);
+ typedef boost::random::hyperexponential_distribution<>::result_type result_type;
+ for(std::size_t i = 0; i < 10; ++i)
+ {
+ const result_type value = dist(gen);
+ use(value);
+ BOOST_CHECK_GE(value, static_cast<result_type>(0));
+ const result_type value_r = dist_r(gen);
+ use(value_r);
+ BOOST_CHECK_GE(value_r, static_cast<result_type>(0));
+ const result_type value_param = dist_r(gen, dist.param());
+ use(value_param);
+ BOOST_CHECK_GE(value_param, static_cast<result_type>(0));
+ const result_type value_r_param = dist(gen, dist_r.param());
+ use(value_r_param);
+ BOOST_CHECK_GE(value_r_param, static_cast<result_type>(0));
+ }
+}
+
+BOOST_AUTO_TEST_CASE( test_generation_float )
+{
+ //const double tol = detail::make_tolerance<double>();
+
+ const std::vector<double> probs = boost::assign::list_of(0.1)(0.2)(0.3)(0.4);
+ const std::vector<double> rates = boost::assign::list_of(1.0)(2.0)(3.0)(4.0);
+
+ boost::lagged_fibonacci607 gen;
+
+ boost::random::hyperexponential_distribution<> dist;
+ boost::random::hyperexponential_distribution<> dist_r(probs, rates);
+ typedef boost::random::hyperexponential_distribution<>::result_type result_type;
+ for(std::size_t i = 0; i < 10; ++i)
+ {
+ const result_type value = dist(gen);
+ use(value);
+ BOOST_CHECK_GE(value, static_cast<result_type>(0));
+ const result_type value_r = dist_r(gen);
+ use(value_r);
+ BOOST_CHECK_GE(value_r, static_cast<result_type>(0));
+ const result_type value_param = dist_r(gen, dist.param());
+ use(value_param);
+ BOOST_CHECK_GE(value_param, static_cast<result_type>(0));
+ const result_type value_r_param = dist(gen, dist_r.param());
+ use(value_r_param);
+ BOOST_CHECK_GE(value_r_param, static_cast<result_type>(0));
+ }
+}
diff --git a/src/boost/libs/random/test/test_independent_bits31.cpp b/src/boost/libs/random/test/test_independent_bits31.cpp
new file mode 100644
index 000000000..aaa3f10a4
--- /dev/null
+++ b/src/boost/libs/random/test/test_independent_bits31.cpp
@@ -0,0 +1,26 @@
+/* test_independent_bits31.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/independent_bits.hpp>
+#include <boost/random/linear_congruential.hpp>
+
+typedef boost::random::independent_bits_engine<boost::random::minstd_rand0, 31, boost::uint32_t> independent_bits31;
+#define BOOST_RANDOM_URNG independent_bits31
+
+#define BOOST_RANDOM_SEED_WORDS 1
+
+#define BOOST_RANDOM_VALIDATION_VALUE 26292962U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 364481529U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 1399154219U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xC1A63AF0U, 0xD66C0614U, 0xADE076B1U, 0xC1DAE13FU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_independent_bits32.cpp b/src/boost/libs/random/test/test_independent_bits32.cpp
new file mode 100644
index 000000000..6534e8647
--- /dev/null
+++ b/src/boost/libs/random/test/test_independent_bits32.cpp
@@ -0,0 +1,26 @@
+/* test_independent_bits32.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/independent_bits.hpp>
+#include <boost/random/mersenne_twister.hpp>
+
+typedef boost::random::independent_bits_engine<boost::random::mt19937, 32, boost::uint32_t> independent_bits32;
+#define BOOST_RANDOM_URNG independent_bits32
+
+#define BOOST_RANDOM_SEED_WORDS 624
+
+#define BOOST_RANDOM_VALIDATION_VALUE 4123659995U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 666528879U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 3408548740U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xD091BB5CU, 0x22AE9EF6U, 0xE7E1FAEEU, 0xD5C31F79U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_knuth_b.cpp b/src/boost/libs/random/test/test_knuth_b.cpp
new file mode 100644
index 000000000..7e5b78b03
--- /dev/null
+++ b/src/boost/libs/random/test/test_knuth_b.cpp
@@ -0,0 +1,26 @@
+/* test_knuth_b.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/shuffle_order.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::knuth_b
+
+#define BOOST_RANDOM_SEED_WORDS 1
+
+// validation from the C++0x draft (n3090)
+#define BOOST_RANDOM_VALIDATION_VALUE 1112339016U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 202352021U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 1692601883U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x5D189C63U, 0xD0544F0EU, 0x15B0E78FU, 0xD814D654U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_kreutzer1986.cpp b/src/boost/libs/random/test/test_kreutzer1986.cpp
new file mode 100644
index 000000000..27035252d
--- /dev/null
+++ b/src/boost/libs/random/test/test_kreutzer1986.cpp
@@ -0,0 +1,26 @@
+/* test_kreutzer1986.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/shuffle_order.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::kreutzer1986
+
+#define BOOST_RANDOM_SEED_WORDS 1
+
+// validation by experiment from Harry Erwin's generator.h (private e-mail)
+#define BOOST_RANDOM_VALIDATION_VALUE 139726U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 589731U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 163138U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x3EADAB08U, 0x85E481CEU, 0xCF84AEA5U, 0x39D4395BU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci.cpp b/src/boost/libs/random/test/test_lagged_fibonacci.cpp
new file mode 100644
index 000000000..7f69bcdb9
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci.cpp
@@ -0,0 +1,25 @@
+/* test_lagged_fibonacci.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+typedef boost::random::lagged_fibonacci_engine<boost::uint32_t, 24, 607, 273> lagged_fibonacci;
+#define BOOST_RANDOM_URNG lagged_fibonacci
+
+#define BOOST_RANDOM_SEED_WORDS 607
+
+#define BOOST_RANDOM_VALIDATION_VALUE 3543833U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 1364481U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 4372778U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xF61A5094U, 0xFC4BA046U, 0xF1C41E92U, 0x3D82FE61U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci1279.cpp b/src/boost/libs/random/test/test_lagged_fibonacci1279.cpp
new file mode 100644
index 000000000..69a12f1ce
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci1279.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci1279.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci1279
+
+#define BOOST_RANDOM_SEED_WORDS 1279*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.39647253381274083
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.97108839261370505
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.56042480761195179
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x4D102C47U, 0xC4E610D7U, 0xF29333BEU, 0x6E45EBE7U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci19937.cpp b/src/boost/libs/random/test/test_lagged_fibonacci19937.cpp
new file mode 100644
index 000000000..f28a71deb
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci19937.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci19937.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci19937
+
+#define BOOST_RANDOM_SEED_WORDS 19937*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.24396310480293693
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.95892429604358043
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.0029754638678802792
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x5CE9850CU, 0xAA20067BU, 0x4E48643BU, 0xA4A59F4BU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci2281.cpp b/src/boost/libs/random/test/test_lagged_fibonacci2281.cpp
new file mode 100644
index 000000000..b87ab828d
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci2281.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci2281.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci2281
+
+#define BOOST_RANDOM_SEED_WORDS 2281*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.91955231927349246
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.4447517699440553
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.087280273457821522
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x7EB0882AU, 0xCE09BE60U, 0xD53046CFU, 0x93257E41U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci23209.cpp b/src/boost/libs/random/test/test_lagged_fibonacci23209.cpp
new file mode 100644
index 000000000..84918d971
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci23209.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci23209.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci23209
+
+#define BOOST_RANDOM_SEED_WORDS 23209*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.086299988971202168
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.63611281281476195
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.0019836425785868528
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x4301DE0AU, 0xAD2584E3U, 0x7C28463CU, 0x74848542U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci3217.cpp b/src/boost/libs/random/test/test_lagged_fibonacci3217.cpp
new file mode 100644
index 000000000..f5bcf10f6
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci3217.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci3217.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci3217
+
+#define BOOST_RANDOM_SEED_WORDS 3217*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.54223093970093927
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.073852702370395207
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.1805114746514036
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x4938F127U, 0x86C65CFEU, 0x65356579U, 0xA6CDC325U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci4423.cpp b/src/boost/libs/random/test/test_lagged_fibonacci4423.cpp
new file mode 100644
index 000000000..f19d4e208
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci4423.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci4423.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci4423
+
+#define BOOST_RANDOM_SEED_WORDS 4423*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.23188533286820601
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.3872440622693567
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.012893676760814543
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x6D4DBAFU, 0x8039C1A9U, 0x3DA53D58U, 0x95155BE5U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci44497.cpp b/src/boost/libs/random/test/test_lagged_fibonacci44497.cpp
new file mode 100644
index 000000000..098308909
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci44497.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci44497.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci44497
+
+#define BOOST_RANDOM_SEED_WORDS 44497*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.12519369894159738
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.92285669730527431
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.0019836425785868528
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x6A2DCEA9U, 0x4668EFB4U, 0x711E352FU, 0xA963C43BU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci607.cpp b/src/boost/libs/random/test/test_lagged_fibonacci607.cpp
new file mode 100644
index 000000000..3095414a4
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci607.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci607.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci607
+
+#define BOOST_RANDOM_SEED_WORDS 607*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.039230772001715764
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.73105942788451372
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.72330291632639643
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x78EB0905U, 0x61766547U, 0xCB507F64U, 0x94FA3EC0U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lagged_fibonacci9689.cpp b/src/boost/libs/random/test/test_lagged_fibonacci9689.cpp
new file mode 100644
index 000000000..d8af5e677
--- /dev/null
+++ b/src/boost/libs/random/test/test_lagged_fibonacci9689.cpp
@@ -0,0 +1,24 @@
+/* test_lagged_fibonacci9689.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lagged_fibonacci.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::lagged_fibonacci9689
+
+#define BOOST_RANDOM_SEED_WORDS 9689*2
+
+#define BOOST_RANDOM_VALIDATION_VALUE 0.059230573043926427
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 0.80900890657466462
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 0.0039672851571737056
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x32EF18BEU, 0x79277C11U, 0xA383438U, 0x32155952U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_laplace.cpp b/src/boost/libs/random/test/test_laplace.cpp
new file mode 100644
index 000000000..a7fba0dfc
--- /dev/null
+++ b/src/boost/libs/random/test/test_laplace.cpp
@@ -0,0 +1,28 @@
+/* test_laplace.cpp
+ *
+ * Copyright Steven Watanabe 2014
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/laplace_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/laplace.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::laplace_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME laplace
+#define BOOST_MATH_DISTRIBUTION boost::math::laplace
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME mean
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(-n, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME beta
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_laplace_distribution.cpp b/src/boost/libs/random/test/test_laplace_distribution.cpp
new file mode 100644
index 000000000..ac5f1185b
--- /dev/null
+++ b/src/boost/libs/random/test/test_laplace_distribution.cpp
@@ -0,0 +1,36 @@
+/* test_laplace_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/laplace_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::laplace_distribution<>
+#define BOOST_RANDOM_ARG1 mean
+#define BOOST_RANDOM_ARG2 beta
+#define BOOST_RANDOM_ARG1_DEFAULT 0.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS (-100.0)
+#define BOOST_RANDOM_TEST1_MAX 0
+
+#define BOOST_RANDOM_TEST2_PARAMS (100.0)
+#define BOOST_RANDOM_TEST2_MIN 0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_linear_feedback_shift.cpp b/src/boost/libs/random/test/test_linear_feedback_shift.cpp
new file mode 100644
index 000000000..7ab70017b
--- /dev/null
+++ b/src/boost/libs/random/test/test_linear_feedback_shift.cpp
@@ -0,0 +1,25 @@
+/* test_linear_feedback_shift.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/linear_feedback_shift.hpp>
+
+typedef boost::random::linear_feedback_shift_engine<boost::uint32_t, 32, 31, 13, 12> linear_feedback_shift;
+#define BOOST_RANDOM_URNG linear_feedback_shift
+
+#define BOOST_RANDOM_SEED_WORDS 1
+
+#define BOOST_RANDOM_VALIDATION_VALUE 981440277U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 3709603036U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 3112279337U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x154005U, 0x54005502U, 0x5502BD4U, 0x2BD4005U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_lognormal.cpp b/src/boost/libs/random/test/test_lognormal.cpp
new file mode 100644
index 000000000..24cbe13d5
--- /dev/null
+++ b/src/boost/libs/random/test/test_lognormal.cpp
@@ -0,0 +1,28 @@
+/* test_lognormal.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lognormal_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/lognormal.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::lognormal_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME lognormal
+#define BOOST_MATH_DISTRIBUTION boost::math::lognormal
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME m
+#define BOOST_RANDOM_ARG1_DEFAULT 10.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(-n, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME s
+#define BOOST_RANDOM_ARG2_DEFAULT 10.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.0001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_lognormal_distribution.cpp b/src/boost/libs/random/test/test_lognormal_distribution.cpp
new file mode 100644
index 000000000..707d355e7
--- /dev/null
+++ b/src/boost/libs/random/test/test_lognormal_distribution.cpp
@@ -0,0 +1,36 @@
+/* test_lognormal_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/lognormal_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::lognormal_distribution<>
+#define BOOST_RANDOM_ARG1 m
+#define BOOST_RANDOM_ARG2 s
+#define BOOST_RANDOM_ARG1_DEFAULT 0.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0.0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0.0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0.0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS (-100.0)
+#define BOOST_RANDOM_TEST1_MAX 1
+
+#define BOOST_RANDOM_TEST2_PARAMS (100.0)
+#define BOOST_RANDOM_TEST2_MIN 1
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_minstd_rand.cpp b/src/boost/libs/random/test/test_minstd_rand.cpp
new file mode 100644
index 000000000..1212c57f2
--- /dev/null
+++ b/src/boost/libs/random/test/test_minstd_rand.cpp
@@ -0,0 +1,26 @@
+/* test_minstd_rand.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/linear_congruential.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::minstd_rand
+
+#define BOOST_RANDOM_SEED_WORDS 1
+
+// validation values from the publications
+#define BOOST_RANDOM_VALIDATION_VALUE 399268537U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 1000962296U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 182651141U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x8400BC8EU, 0xF45B895FU, 0x145F0F91U, 0xE5F8F088U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_minstd_rand0.cpp b/src/boost/libs/random/test/test_minstd_rand0.cpp
new file mode 100644
index 000000000..ec54e42af
--- /dev/null
+++ b/src/boost/libs/random/test/test_minstd_rand0.cpp
@@ -0,0 +1,26 @@
+/* test_minstd_rand0.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/linear_congruential.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::minstd_rand0
+
+#define BOOST_RANDOM_SEED_WORDS 1
+
+// validation values from the publications
+#define BOOST_RANDOM_VALIDATION_VALUE 1043618065U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 1274759829U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 1263181168U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xC00041A6U, 0xCD8358EBU, 0x430A4B7AU, 0x31B781ADU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_mt11213b.cpp b/src/boost/libs/random/test/test_mt11213b.cpp
new file mode 100644
index 000000000..62e2644f6
--- /dev/null
+++ b/src/boost/libs/random/test/test_mt11213b.cpp
@@ -0,0 +1,26 @@
+/* test_mt11213b.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/mersenne_twister.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::mt11213b
+
+#define BOOST_RANDOM_SEED_WORDS 351
+
+#define BOOST_RANDOM_VALIDATION_VALUE 3809585648U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 2936939529U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 2434563197U
+#define BOOST_RANDOM_DISCARD_COUNT1 9307
+#define BOOST_RANDOM_DISCARD_COUNT2 20000000
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xEF3F3F3FU, 0x70082175U, 0xDAF6EAF5U, 0x2A16A63EU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_mt19937.cpp b/src/boost/libs/random/test/test_mt19937.cpp
new file mode 100644
index 000000000..568d66891
--- /dev/null
+++ b/src/boost/libs/random/test/test_mt19937.cpp
@@ -0,0 +1,81 @@
+/* test_mt19937.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/mersenne_twister.hpp>
+#include <algorithm>
+#include <vector>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::mt19937
+
+#define BOOST_RANDOM_SEED_WORDS 624
+
+// validation by experiment from mt19937.c
+#define BOOST_RANDOM_VALIDATION_VALUE 4123659995U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 666528879U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 3408548740U
+#define BOOST_RANDOM_DISCARD_COUNT1 9307
+#define BOOST_RANDOM_DISCARD_COUNT2 20000000
+#define BOOST_RANDOM_DISCARD_MAX
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xD091BB5CU, 0x22AE9EF6U, 0xE7E1FAEEU, 0xD5C31F79U }
+
+#include "test_generator.ipp"
+
+struct seed_seq_0 {
+ template<class It>
+ void generate(It begin, It end) const {
+ std::fill(begin, end, boost::uint32_t(0));
+ }
+};
+
+struct seed_seq_1 {
+ template<class It>
+ void generate(It begin, It end) const {
+ std::fill(begin, end, boost::uint32_t(0));
+ *(end - 1) = 1;
+ }
+};
+
+BOOST_AUTO_TEST_CASE(test_special_seed) {
+ {
+ seed_seq_1 seed;
+ std::vector<boost::uint32_t> vec(624);
+ seed.generate(vec.begin(), vec.end());
+
+ std::vector<boost::uint32_t>::iterator it = vec.begin();
+ boost::mt19937 gen1(it, vec.end());
+ BOOST_CHECK_EQUAL(gen1(), 0u);
+ BOOST_CHECK_EQUAL(gen1(), 0u);
+
+ boost::mt19937 gen2(seed);
+ BOOST_CHECK_EQUAL(gen2(), 0u);
+ BOOST_CHECK_EQUAL(gen2(), 0u);
+
+ BOOST_CHECK_EQUAL(gen1, gen2);
+ }
+ {
+ seed_seq_0 seed;
+ std::vector<boost::uint32_t> vec(624);
+ seed.generate(vec.begin(), vec.end());
+
+ std::vector<boost::uint32_t>::iterator it = vec.begin();
+ boost::mt19937 gen1(it, vec.end());
+ BOOST_CHECK_EQUAL(gen1(), 1141379330u);
+ BOOST_CHECK_EQUAL(gen1(), 0u);
+
+ boost::mt19937 gen2(seed);
+ BOOST_CHECK_EQUAL(gen2(), 1141379330u);
+ BOOST_CHECK_EQUAL(gen2(), 0u);
+
+ BOOST_CHECK_EQUAL(gen1, gen2);
+ }
+}
diff --git a/src/boost/libs/random/test/test_mt19937_64.cpp b/src/boost/libs/random/test/test_mt19937_64.cpp
new file mode 100644
index 000000000..e3300847b
--- /dev/null
+++ b/src/boost/libs/random/test/test_mt19937_64.cpp
@@ -0,0 +1,28 @@
+/* test_mt119937_64.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::mt19937_64
+
+#define BOOST_RANDOM_SEED_WORDS 624
+
+// validation from the C++0x draft (n3090)
+#define BOOST_RANDOM_VALIDATION_VALUE UINT64_C(9981545732273789042)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE UINT64_C(12176471137395770412)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE UINT64_C(13543700832025962283)
+#define BOOST_RANDOM_DISCARD_COUNT1 9307
+#define BOOST_RANDOM_DISCARD_COUNT2 20000000
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xF6F6AEA6U, 0xC96D191CU, 0x8BC80F1CU, 0x401F7AC7U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_negative_binomial.cpp b/src/boost/libs/random/test/test_negative_binomial.cpp
new file mode 100644
index 000000000..e2968611e
--- /dev/null
+++ b/src/boost/libs/random/test/test_negative_binomial.cpp
@@ -0,0 +1,30 @@
+/* test_negative_binomial.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/negative_binomial_distribution.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_01.hpp>
+#include <boost/math/distributions/negative_binomial.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::negative_binomial_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME negative_binomial
+#define BOOST_MATH_DISTRIBUTION boost::math::negative_binomial
+#define BOOST_RANDOM_ARG1_TYPE int
+#define BOOST_RANDOM_ARG1_NAME n
+#define BOOST_RANDOM_ARG1_DEFAULT 100000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_int<>(0, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME p
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_01<>()
+#define BOOST_RANDOM_DISTRIBUTION_MAX n
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_negative_binomial_distribution.cpp b/src/boost/libs/random/test/test_negative_binomial_distribution.cpp
new file mode 100644
index 000000000..c6cd6c917
--- /dev/null
+++ b/src/boost/libs/random/test/test_negative_binomial_distribution.cpp
@@ -0,0 +1,37 @@
+/* test_negative_binomial_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/negative_binomial_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::negative_binomial_distribution<>
+#define BOOST_RANDOM_ARG1 k
+#define BOOST_RANDOM_ARG2 p
+#define BOOST_RANDOM_ARG1_DEFAULT 1
+#define BOOST_RANDOM_ARG2_DEFAULT 0.5
+#define BOOST_RANDOM_ARG1_VALUE 10
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<int>::max)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<int>::max)()
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<int>::max)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 10
+
+#define BOOST_RANDOM_TEST2_PARAMS (100, 0.5)
+#define BOOST_RANDOM_TEST2_MIN 50
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_non_central_chi_squared.cpp b/src/boost/libs/random/test/test_non_central_chi_squared.cpp
new file mode 100644
index 000000000..914b7752e
--- /dev/null
+++ b/src/boost/libs/random/test/test_non_central_chi_squared.cpp
@@ -0,0 +1,29 @@
+/* test_non_central_chi_squared.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Copyright Thijs van den Berg 2014
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/non_central_chi_squared_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/non_central_chi_squared.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::non_central_chi_squared_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME non_central_chi_squared
+#define BOOST_MATH_DISTRIBUTION boost::math::non_central_chi_squared
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME k
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(k) boost::uniform_real<>(0.00001, k)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME lambda
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(lambda) boost::uniform_real<>(0.00001, lambda)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_non_central_chi_squared_distribution.cpp b/src/boost/libs/random/test/test_non_central_chi_squared_distribution.cpp
new file mode 100644
index 000000000..0c88134aa
--- /dev/null
+++ b/src/boost/libs/random/test/test_non_central_chi_squared_distribution.cpp
@@ -0,0 +1,39 @@
+/* test_non_central_chi_squared_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Copyright Thijs van den Berg 2014
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/non_central_chi_squared_distribution.hpp>
+#include <limits>
+
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::non_central_chi_squared_distribution<>
+#define BOOST_RANDOM_ARG1 k
+#define BOOST_RANDOM_ARG2 lambda
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 4.0
+#define BOOST_RANDOM_ARG2_VALUE 42.0
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 100.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (10000.0)
+#define BOOST_RANDOM_TEST2_MIN 100.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_normal.cpp b/src/boost/libs/random/test/test_normal.cpp
new file mode 100644
index 000000000..e7bbb304a
--- /dev/null
+++ b/src/boost/libs/random/test/test_normal.cpp
@@ -0,0 +1,28 @@
+/* test_normal.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/normal_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/normal.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::normal_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME normal
+#define BOOST_MATH_DISTRIBUTION boost::math::normal
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME m
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(-n, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME s
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_normal_distribution.cpp b/src/boost/libs/random/test/test_normal_distribution.cpp
new file mode 100644
index 000000000..47c88424f
--- /dev/null
+++ b/src/boost/libs/random/test/test_normal_distribution.cpp
@@ -0,0 +1,36 @@
+/* test_normal_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/normal_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::normal_distribution<>
+#define BOOST_RANDOM_ARG1 mean
+#define BOOST_RANDOM_ARG2 sigma
+#define BOOST_RANDOM_ARG1_DEFAULT 0.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS (-100.0)
+#define BOOST_RANDOM_TEST1_MAX 0
+
+#define BOOST_RANDOM_TEST2_PARAMS (100.0)
+#define BOOST_RANDOM_TEST2_MIN 0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_old_uniform_int.cpp b/src/boost/libs/random/test/test_old_uniform_int.cpp
new file mode 100644
index 000000000..442f22fa9
--- /dev/null
+++ b/src/boost/libs/random/test/test_old_uniform_int.cpp
@@ -0,0 +1,26 @@
+/* test_old_uniform_int.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_int.hpp>
+#include <boost/math/distributions/uniform.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::uniform_int<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME uniform_int
+#define BOOST_MATH_DISTRIBUTION boost::math::uniform
+#define BOOST_RANDOM_ARG1_TYPE int
+#define BOOST_RANDOM_ARG1_NAME b
+#define BOOST_RANDOM_ARG1_DEFAULT 1000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_int<>(0, n)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (0, b)
+#define BOOST_MATH_DISTRIBUTION_INIT (0, b+1)
+#define BOOST_RANDOM_DISTRIBUTION_MAX b
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_old_uniform_int_distribution.cpp b/src/boost/libs/random/test/test_old_uniform_int_distribution.cpp
new file mode 100644
index 000000000..bdae26461
--- /dev/null
+++ b/src/boost/libs/random/test/test_old_uniform_int_distribution.cpp
@@ -0,0 +1,78 @@
+/* test_old_uniform_int_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_int.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::uniform_int<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 0
+#define BOOST_RANDOM_ARG2_DEFAULT 9
+#define BOOST_RANDOM_ARG1_VALUE 5
+#define BOOST_RANDOM_ARG2_VALUE 250
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX 9
+#define BOOST_RANDOM_DIST1_MIN 5
+#define BOOST_RANDOM_DIST1_MAX 9
+#define BOOST_RANDOM_DIST2_MIN 5
+#define BOOST_RANDOM_DIST2_MAX 250
+
+#define BOOST_RANDOM_TEST1_PARAMS (0, 9)
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 9
+
+#define BOOST_RANDOM_TEST2_PARAMS (10, 19)
+#define BOOST_RANDOM_TEST2_MIN 10
+#define BOOST_RANDOM_TEST2_MAX 19
+
+#include "test_distribution.ipp"
+
+#define BOOST_RANDOM_UNIFORM_INT boost::uniform_int
+
+#include "test_uniform_int.ipp"
+
+#include <algorithm>
+#include <boost/random/random_number_generator.hpp>
+
+// Test that uniform_int<> can be used with std::random_shuffle
+// Author: Jos Hickson
+BOOST_AUTO_TEST_CASE(test_random_shuffle)
+{
+#ifndef BOOST_NO_CXX98_RANDOM_SHUFFLE
+ typedef boost::uniform_int<> distribution_type;
+ typedef boost::variate_generator<boost::mt19937 &, distribution_type> generator_type;
+
+ boost::mt19937 engine1(1234);
+ boost::mt19937 engine2(1234);
+
+ boost::random::random_number_generator<boost::mt19937> referenceRand(engine1);
+
+ distribution_type dist(0,10);
+ generator_type testRand(engine2, dist);
+
+ std::vector<int> referenceVec;
+
+ for (int i = 0; i < 200; ++i) {
+ referenceVec.push_back(i);
+ }
+
+ std::vector<int> testVec(referenceVec);
+
+ std::random_shuffle(referenceVec.begin(), referenceVec.end(), referenceRand);
+ std::random_shuffle(testVec.begin(), testVec.end(), testRand);
+
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ testVec.begin(), testVec.end(),
+ referenceVec.begin(), referenceVec.end());
+#endif
+}
diff --git a/src/boost/libs/random/test/test_old_uniform_real.cpp b/src/boost/libs/random/test/test_old_uniform_real.cpp
new file mode 100644
index 000000000..7c65e886b
--- /dev/null
+++ b/src/boost/libs/random/test/test_old_uniform_real.cpp
@@ -0,0 +1,25 @@
+/* test_old_uniform_real.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/uniform.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::uniform_real<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME uniform_real
+#define BOOST_MATH_DISTRIBUTION boost::math::uniform
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME b
+#define BOOST_RANDOM_ARG1_DEFAULT 1000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0, n)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (0, b)
+#define BOOST_MATH_DISTRIBUTION_INIT (0, b)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_old_uniform_real_distribution.cpp b/src/boost/libs/random/test/test_old_uniform_real_distribution.cpp
new file mode 100644
index 000000000..1728fb31f
--- /dev/null
+++ b/src/boost/libs/random/test/test_old_uniform_real_distribution.cpp
@@ -0,0 +1,38 @@
+/* test_old_uniform_real_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_real.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::uniform_real<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 0.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE -0.5
+#define BOOST_RANDOM_ARG2_VALUE 1.5
+
+#define BOOST_RANDOM_DIST0_MIN 0.0
+#define BOOST_RANDOM_DIST0_MAX 1.0
+#define BOOST_RANDOM_DIST1_MIN -0.5
+#define BOOST_RANDOM_DIST1_MAX 1.0
+#define BOOST_RANDOM_DIST2_MIN -0.5
+#define BOOST_RANDOM_DIST2_MAX 1.5
+
+#define BOOST_RANDOM_TEST1_PARAMS (-1.0, 0.0)
+#define BOOST_RANDOM_TEST1_MIN -1.0
+#define BOOST_RANDOM_TEST1_MAX 0.0
+
+#define BOOST_RANDOM_TEST2_PARAMS
+#define BOOST_RANDOM_TEST2_MIN 0.0
+#define BOOST_RANDOM_TEST2_MAX 1.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_piecewise_constant.cpp b/src/boost/libs/random/test/test_piecewise_constant.cpp
new file mode 100644
index 000000000..8261def96
--- /dev/null
+++ b/src/boost/libs/random/test/test_piecewise_constant.cpp
@@ -0,0 +1,158 @@
+/* test_piecewise_constant.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/piecewise_constant_distribution.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+#include <boost/range/algorithm/lower_bound.hpp>
+#include <boost/range/numeric.hpp>
+#include <vector>
+#include <iostream>
+#include <iomanip>
+
+#include "statistic_tests.hpp"
+
+class piecewise_constant
+{
+public:
+ piecewise_constant(const std::vector<double>& intervals, const std::vector<double>& weights)
+ : intervals(intervals),
+ cumulative(1, 0.0)
+ {
+ boost::partial_sum(weights, std::back_inserter(cumulative));
+ for(std::vector<double>::iterator iter = cumulative.begin(), end = cumulative.end();
+ iter != end; ++iter)
+ {
+ *iter /= cumulative.back();
+ }
+ }
+
+ double cdf(double x) const
+ {
+ std::size_t index = boost::lower_bound(intervals, x) - intervals.begin();
+ if(index == 0) return 0;
+ else if(index == intervals.size()) return 1;
+ else {
+ double lower_weight = cumulative[index - 1];
+ double upper_weight = cumulative[index];
+ double lower = intervals[index - 1];
+ double upper = intervals[index];
+ return lower_weight + (x - lower) / (upper - lower) * (upper_weight - lower_weight);
+ }
+ }
+private:
+ std::vector<double> intervals;
+ std::vector<double> cumulative;
+};
+
+double cdf(const piecewise_constant& dist, double x)
+{
+ return dist.cdf(x);
+}
+
+bool do_test(int n, int max) {
+ std::cout << "running piecewise_constant(p0, p1, ..., p" << n-1 << ")" << " " << max << " times: " << std::flush;
+
+ std::vector<double> weights;
+ {
+ boost::mt19937 egen;
+ for(int i = 0; i < n; ++i) {
+ weights.push_back(egen());
+ }
+ }
+ std::vector<double> intervals;
+ for(int i = 0; i <= n; ++i) {
+ intervals.push_back(i);
+ }
+
+ piecewise_constant expected(intervals, weights);
+
+ boost::random::piecewise_constant_distribution<> dist(intervals, weights);
+ boost::mt19937 gen;
+ kolmogorov_experiment test(max);
+ boost::variate_generator<boost::mt19937&, boost::random::piecewise_constant_distribution<> > vgen(gen, dist);
+
+ double prob = test.probability(test.run(vgen, expected));
+
+ bool result = prob < 0.99;
+ const char* err = result? "" : "*";
+ std::cout << std::setprecision(17) << prob << err << std::endl;
+
+ std::cout << std::setprecision(6);
+
+ return result;
+}
+
+bool do_tests(int repeat, int max_n, int trials) {
+ boost::mt19937 gen;
+ boost::uniform_int<> idist(1, max_n);
+ int errors = 0;
+ for(int i = 0; i < repeat; ++i) {
+ if(!do_test(idist(gen), trials)) {
+ ++errors;
+ }
+ }
+ if(errors != 0) {
+ std::cout << "*** " << errors << " errors detected ***" << std::endl;
+ }
+ return errors == 0;
+}
+
+int usage() {
+ std::cerr << "Usage: test_piecewise_constant -r <repeat> -n <max n> -t <trials>" << std::endl;
+ return 2;
+}
+
+template<class T>
+bool handle_option(int& argc, char**& argv, char opt, T& value) {
+ if(argv[0][1] == opt && argc > 1) {
+ --argc;
+ ++argv;
+ value = boost::lexical_cast<T>(argv[0]);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+int main(int argc, char** argv) {
+ int repeat = 10;
+ int max_n = 10;
+ int trials = 1000000;
+
+ if(argc > 0) {
+ --argc;
+ ++argv;
+ }
+ while(argc > 0) {
+ if(argv[0][0] != '-') return usage();
+ else if(!handle_option(argc, argv, 'r', repeat)
+ && !handle_option(argc, argv, 'n', max_n)
+ && !handle_option(argc, argv, 't', trials)) {
+ return usage();
+ }
+ --argc;
+ ++argv;
+ }
+
+ try {
+ if(do_tests(repeat, max_n, trials)) {
+ return 0;
+ } else {
+ return EXIT_FAILURE;
+ }
+ } catch(...) {
+ std::cerr << boost::current_exception_diagnostic_information() << std::endl;
+ return EXIT_FAILURE;
+ }
+}
diff --git a/src/boost/libs/random/test/test_piecewise_constant_distribution.cpp b/src/boost/libs/random/test/test_piecewise_constant_distribution.cpp
new file mode 100644
index 000000000..793c3e657
--- /dev/null
+++ b/src/boost/libs/random/test/test_piecewise_constant_distribution.cpp
@@ -0,0 +1,246 @@
+/* test_piecewise_constant_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/piecewise_constant_distribution.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/assign/list_of.hpp>
+#include <sstream>
+#include <vector>
+#include "concepts.hpp"
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using boost::random::test::RandomNumberDistribution;
+using boost::random::piecewise_constant_distribution;
+BOOST_CONCEPT_ASSERT((RandomNumberDistribution< piecewise_constant_distribution<> >));
+
+struct gen {
+ double operator()(double arg) {
+ if(arg < 100) return 100;
+ else if(arg < 103) return 1;
+ else if(arg < 107) return 2;
+ else if(arg < 111) return 1;
+ else if(arg < 114) return 4;
+ else return 100;
+ }
+};
+
+#define CHECK_SEQUENCE(actual, expected) \
+ do { \
+ std::vector<double> _actual = (actual); \
+ std::vector<double> _expected = (expected); \
+ BOOST_CHECK_EQUAL_COLLECTIONS( \
+ _actual.begin(), _actual.end(), \
+ _expected.begin(), _expected.end()); \
+ } while(false)
+
+using boost::assign::list_of;
+
+BOOST_AUTO_TEST_CASE(test_constructors) {
+ boost::random::piecewise_constant_distribution<> dist;
+ CHECK_SEQUENCE(dist.densities(), list_of(1.0));
+ CHECK_SEQUENCE(dist.intervals(), list_of(0.0)(1.0));
+
+#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+ boost::random::piecewise_constant_distribution<> dist_il = {
+ { 99, 103, 107, 111, 115 },
+ gen()
+ };
+ CHECK_SEQUENCE(dist_il.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(dist_il.densities(), list_of(.03125)(.0625)(.03125)(.125));
+
+ boost::random::piecewise_constant_distribution<> dist_il2 = {
+ { 99 },
+ gen()
+ };
+ CHECK_SEQUENCE(dist_il2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(dist_il2.densities(), list_of(1.0));
+#endif
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(1)(2)(1)(4);
+ std::vector<double> intervals2 = boost::assign::list_of(99);
+ std::vector<double> weights2;
+
+ boost::random::piecewise_constant_distribution<> dist_r(intervals, weights);
+ CHECK_SEQUENCE(dist_r.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(dist_r.densities(), list_of(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_constant_distribution<>
+ dist_r2(intervals2, weights2);
+ CHECK_SEQUENCE(dist_r2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(dist_r2.densities(), list_of(1.0));
+
+ boost::random::piecewise_constant_distribution<> dist_it(
+ intervals.begin(), intervals.end(), weights.begin());
+ CHECK_SEQUENCE(dist_it.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(dist_it.densities(), list_of(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_constant_distribution<> dist_it2(
+ intervals2.begin(), intervals2.end(), weights2.begin());
+ CHECK_SEQUENCE(dist_it2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(dist_it2.densities(), list_of(1.0));
+
+ boost::random::piecewise_constant_distribution<> dist_fun(4, 99,115, gen());
+ CHECK_SEQUENCE(dist_fun.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(dist_fun.densities(), list_of(.03125)(.0625)(.03125)(.125));
+
+ boost::random::piecewise_constant_distribution<>
+ dist_fun2(1, 99, 115, gen());
+ CHECK_SEQUENCE(dist_fun2.intervals(), list_of(99)(115));
+ CHECK_SEQUENCE(dist_fun2.densities(), list_of(0.0625));
+
+ boost::random::piecewise_constant_distribution<> copy(dist);
+ BOOST_CHECK_EQUAL(dist, copy);
+ boost::random::piecewise_constant_distribution<> copy_r(dist_r);
+ BOOST_CHECK_EQUAL(dist_r, copy_r);
+
+ boost::random::piecewise_constant_distribution<> notpow2(3, 99, 111, gen());
+ BOOST_REQUIRE_EQUAL(notpow2.densities().size(), 3u);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.densities()[0], 0.0625, 0.00000000001);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.densities()[1], 0.125, 0.00000000001);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.densities()[2], 0.0625, 0.00000000001);
+ boost::random::piecewise_constant_distribution<> copy_notpow2(notpow2);
+ BOOST_CHECK_EQUAL(notpow2, copy_notpow2);
+}
+
+BOOST_AUTO_TEST_CASE(test_param) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(1)(2)(1)(4);
+ std::vector<double> intervals2 = boost::assign::list_of(0);
+ std::vector<double> weights2;
+ boost::random::piecewise_constant_distribution<> dist(intervals, weights);
+ boost::random::piecewise_constant_distribution<>::param_type
+ param = dist.param();
+ CHECK_SEQUENCE(param.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(param.densities(), list_of(.125)(.25)(.125)(.25));
+ boost::random::piecewise_constant_distribution<> copy1(param);
+ BOOST_CHECK_EQUAL(dist, copy1);
+ boost::random::piecewise_constant_distribution<> copy2;
+ copy2.param(param);
+ BOOST_CHECK_EQUAL(dist, copy2);
+
+ boost::random::piecewise_constant_distribution<>::param_type
+ param_copy = param;
+ BOOST_CHECK_EQUAL(param, param_copy);
+ BOOST_CHECK(param == param_copy);
+ BOOST_CHECK(!(param != param_copy));
+ boost::random::piecewise_constant_distribution<>::param_type param_default;
+ CHECK_SEQUENCE(param_default.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(param_default.densities(), list_of(1.0));
+ BOOST_CHECK(param != param_default);
+ BOOST_CHECK(!(param == param_default));
+
+#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+ boost::random::piecewise_constant_distribution<>::param_type parm_il = {
+ { 99, 103, 107, 111, 115 },
+ gen()
+ };
+ CHECK_SEQUENCE(parm_il.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(parm_il.densities(), list_of(.03125)(.0625)(.03125)(.125));
+
+ boost::random::piecewise_constant_distribution<>::param_type parm_il2 = {
+ { 99 },
+ gen()
+ };
+ CHECK_SEQUENCE(parm_il2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(parm_il2.densities(), list_of(1.0));
+#endif
+
+ boost::random::piecewise_constant_distribution<>::param_type
+ parm_r(intervals, weights);
+ CHECK_SEQUENCE(parm_r.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(parm_r.densities(), list_of(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_constant_distribution<>::param_type
+ parm_r2(intervals2, weights2);
+ CHECK_SEQUENCE(parm_r2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(parm_r2.densities(), list_of(1.0));
+
+ boost::random::piecewise_constant_distribution<>::param_type
+ parm_it(intervals.begin(), intervals.end(), weights.begin());
+ CHECK_SEQUENCE(parm_it.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(parm_it.densities(), list_of(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_constant_distribution<>::param_type
+ parm_it2(intervals2.begin(), intervals2.end(), weights2.begin());
+ CHECK_SEQUENCE(parm_it2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(parm_it2.densities(), list_of(1.0));
+
+ boost::random::piecewise_constant_distribution<>::param_type
+ parm_fun(4, 99, 115, gen());
+ CHECK_SEQUENCE(parm_fun.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(parm_fun.densities(), list_of(.03125)(.0625)(.03125)(.125));
+
+ boost::random::piecewise_constant_distribution<>::param_type
+ parm_fun2(1, 99, 115, gen());
+ CHECK_SEQUENCE(parm_fun2.intervals(), list_of(99)(115));
+ CHECK_SEQUENCE(parm_fun2.densities(), list_of(0.0625));
+}
+
+BOOST_AUTO_TEST_CASE(test_min_max) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(1)(2)(1)(4);
+ boost::random::piecewise_constant_distribution<> dist;
+ BOOST_CHECK_EQUAL((dist.min)(), 0.0);
+ BOOST_CHECK_EQUAL((dist.max)(), 1.0);
+ boost::random::piecewise_constant_distribution<> dist_r(intervals, weights);
+ BOOST_CHECK_EQUAL((dist_r.min)(), 0.0);
+ BOOST_CHECK_EQUAL((dist_r.max)(), 5.0);
+}
+
+BOOST_AUTO_TEST_CASE(test_comparison) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(1)(2)(1)(4);
+ boost::random::piecewise_constant_distribution<> dist;
+ boost::random::piecewise_constant_distribution<> dist_copy(dist);
+ boost::random::piecewise_constant_distribution<> dist_r(intervals, weights);
+ boost::random::piecewise_constant_distribution<> dist_r_copy(dist_r);
+ BOOST_CHECK(dist == dist_copy);
+ BOOST_CHECK(!(dist != dist_copy));
+ BOOST_CHECK(dist_r == dist_r_copy);
+ BOOST_CHECK(!(dist_r != dist_r_copy));
+ BOOST_CHECK(dist != dist_r);
+ BOOST_CHECK(!(dist == dist_r));
+}
+
+BOOST_AUTO_TEST_CASE(test_streaming) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(1)(2)(1)(4);
+ boost::random::piecewise_constant_distribution<> dist(intervals, weights);
+ std::stringstream stream;
+ stream << dist;
+ boost::random::piecewise_constant_distribution<> restored_dist;
+ stream >> restored_dist;
+ BOOST_CHECK_EQUAL(dist, restored_dist);
+}
+
+BOOST_AUTO_TEST_CASE(test_generation) {
+ std::vector<double> intervals = boost::assign::list_of(1)(2);
+ std::vector<double> weights = boost::assign::list_of(1);
+ boost::minstd_rand0 gen;
+ boost::random::piecewise_constant_distribution<> dist;
+ boost::random::piecewise_constant_distribution<> dist_r(intervals, weights);
+ for(int i = 0; i < 10; ++i) {
+ double value = dist(gen);
+ BOOST_CHECK_GE(value, 0.0);
+ BOOST_CHECK_LT(value, 1.0);
+ double value_r = dist_r(gen);
+ BOOST_CHECK_GE(value_r, 1.0);
+ BOOST_CHECK_LT(value_r, 2.0);
+ double value_param = dist_r(gen, dist.param());
+ BOOST_CHECK_GE(value_param, 0.0);
+ BOOST_CHECK_LT(value_param, 1.0);
+ double value_r_param = dist(gen, dist_r.param());
+ BOOST_CHECK_GE(value_r_param, 1.0);
+ BOOST_CHECK_LT(value_r_param, 2.0);
+ }
+}
diff --git a/src/boost/libs/random/test/test_piecewise_linear.cpp b/src/boost/libs/random/test/test_piecewise_linear.cpp
new file mode 100644
index 000000000..4a03c5f14
--- /dev/null
+++ b/src/boost/libs/random/test/test_piecewise_linear.cpp
@@ -0,0 +1,175 @@
+/* test_piecewise_linear.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/piecewise_linear_distribution.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+#include <boost/range/algorithm/lower_bound.hpp>
+#include <boost/range/numeric.hpp>
+#include <vector>
+#include <iostream>
+#include <iomanip>
+
+#include "statistic_tests.hpp"
+
+class piecewise_linear
+{
+public:
+ piecewise_linear(const std::vector<double>& intervals, const std::vector<double>& weights)
+ : intervals(intervals),
+ weights(weights),
+ cumulative(1, 0.0)
+ {
+ for(std::size_t i = 0; i < weights.size() - 1; ++i) {
+ cumulative.push_back((weights[i] + weights[i + 1]) / 2);
+ }
+ boost::partial_sum(cumulative, cumulative.begin());
+ double sum = cumulative.back();
+ for(std::vector<double>::iterator iter = cumulative.begin(), end = cumulative.end();
+ iter != end; ++iter)
+ {
+ *iter /= sum;
+ }
+ for(std::vector<double>::iterator iter = this->weights.begin(), end = this->weights.end();
+ iter != end; ++iter)
+ {
+ *iter /= sum;
+ }
+ assert(this->weights.size() == this->intervals.size());
+ assert(this->weights.size() == this->cumulative.size());
+ }
+
+ double cdf(double x) const
+ {
+ std::size_t index = boost::lower_bound(intervals, x) - intervals.begin();
+ if(index == 0) return 0;
+ else if(index == intervals.size()) return 1;
+ else {
+ double start = cumulative[index - 1];
+ double lower_weight = weights[index - 1];
+ double upper_weight = weights[index];
+ double lower = intervals[index - 1];
+ double upper = intervals[index];
+ double mid_weight = (lower_weight * (upper - x) + upper_weight * (x - lower)) / (upper - lower);
+ double segment_area = (x - lower) * (mid_weight + lower_weight) / 2;
+ return start + segment_area;
+ }
+ }
+private:
+ std::vector<double> intervals;
+ std::vector<double> weights;
+ std::vector<double> cumulative;
+};
+
+double cdf(const piecewise_linear& dist, double x)
+{
+ return dist.cdf(x);
+}
+
+bool do_test(int n, int max) {
+ std::cout << "running piecewise_linear(p0, p1, ..., p" << n-1 << ")" << " " << max << " times: " << std::flush;
+
+ std::vector<double> weights;
+ {
+ boost::mt19937 egen;
+ for(int i = 0; i < n; ++i) {
+ weights.push_back(egen());
+ }
+ }
+ std::vector<double> intervals;
+ for(int i = 0; i < n; ++i) {
+ intervals.push_back(i);
+ }
+
+ piecewise_linear expected(intervals, weights);
+
+ boost::random::piecewise_linear_distribution<> dist(intervals, weights);
+ boost::mt19937 gen;
+ kolmogorov_experiment test(max);
+ boost::variate_generator<boost::mt19937&, boost::random::piecewise_linear_distribution<> > vgen(gen, dist);
+
+ double prob = test.probability(test.run(vgen, expected));
+
+ bool result = prob < 0.99;
+ const char* err = result? "" : "*";
+ std::cout << std::setprecision(17) << prob << err << std::endl;
+
+ std::cout << std::setprecision(6);
+
+ return result;
+}
+
+bool do_tests(int repeat, int max_n, int trials) {
+ boost::mt19937 gen;
+ boost::uniform_int<> idist(2, max_n);
+ int errors = 0;
+ for(int i = 0; i < repeat; ++i) {
+ if(!do_test(idist(gen), trials)) {
+ ++errors;
+ }
+ }
+ if(errors != 0) {
+ std::cout << "*** " << errors << " errors detected ***" << std::endl;
+ }
+ return errors == 0;
+}
+
+int usage() {
+ std::cerr << "Usage: test_piecewise_linear -r <repeat> -n <max n> -t <trials>" << std::endl;
+ return 2;
+}
+
+template<class T>
+bool handle_option(int& argc, char**& argv, char opt, T& value) {
+ if(argv[0][1] == opt && argc > 1) {
+ --argc;
+ ++argv;
+ value = boost::lexical_cast<T>(argv[0]);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+int main(int argc, char** argv) {
+ int repeat = 10;
+ int max_n = 10;
+ int trials = 1000000;
+
+ if(argc > 0) {
+ --argc;
+ ++argv;
+ }
+ while(argc > 0) {
+ if(argv[0][0] != '-') return usage();
+ else if(!handle_option(argc, argv, 'r', repeat)
+ && !handle_option(argc, argv, 'n', max_n)
+ && !handle_option(argc, argv, 't', trials)) {
+ return usage();
+ }
+ --argc;
+ ++argv;
+ }
+
+ try {
+ if(do_tests(repeat, max_n, trials)) {
+ return 0;
+ } else {
+ return EXIT_FAILURE;
+ }
+ } catch(...) {
+ std::cerr << boost::current_exception_diagnostic_information() << std::endl;
+ return EXIT_FAILURE;
+ }
+}
diff --git a/src/boost/libs/random/test/test_piecewise_linear_distribution.cpp b/src/boost/libs/random/test/test_piecewise_linear_distribution.cpp
new file mode 100644
index 000000000..9426de283
--- /dev/null
+++ b/src/boost/libs/random/test/test_piecewise_linear_distribution.cpp
@@ -0,0 +1,252 @@
+/* test_piecewise_linear_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/piecewise_linear_distribution.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/assign/list_of.hpp>
+#include <sstream>
+#include <vector>
+#include "concepts.hpp"
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using boost::random::test::RandomNumberDistribution;
+using boost::random::piecewise_linear_distribution;
+BOOST_CONCEPT_ASSERT((RandomNumberDistribution< piecewise_linear_distribution<> >));
+
+struct gen {
+ double operator()(double arg) {
+ if(arg < 97) return 100;
+ else if(arg < 101) return 3;
+ else if(arg < 105) return 1;
+ else if(arg < 109) return 2;
+ else if(arg < 113) return 1;
+ else if(arg < 117) return 5;
+ else return 100;
+ }
+};
+
+#define CHECK_SEQUENCE(actual, expected) \
+ do { \
+ std::vector<double> _actual = (actual); \
+ std::vector<double> _expected = (expected); \
+ BOOST_CHECK_EQUAL_COLLECTIONS( \
+ _actual.begin(), _actual.end(), \
+ _expected.begin(), _expected.end()); \
+ } while(false)
+
+using boost::assign::list_of;
+
+BOOST_AUTO_TEST_CASE(test_constructors) {
+ boost::random::piecewise_linear_distribution<> dist;
+ CHECK_SEQUENCE(dist.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(dist.densities(), list_of(1.0)(1.0));
+
+#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+ boost::random::piecewise_linear_distribution<> dist_il = {
+ { 99, 103, 107, 111, 115 },
+ gen()
+ };
+ CHECK_SEQUENCE(dist_il.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(dist_il.densities(),
+ list_of(.09375)(.03125)(0.0625)(.03125)(.15625));
+
+ boost::random::piecewise_linear_distribution<> dist_il2 = {
+ { 99 },
+ gen()
+ };
+ CHECK_SEQUENCE(dist_il2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(dist_il2.densities(), list_of(1.0)(1.0));
+#endif
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(3)(1)(2)(1)(2);
+ std::vector<double> intervals2 = boost::assign::list_of(99);
+ std::vector<double> weights2 = boost::assign::list_of(2);
+
+ boost::random::piecewise_linear_distribution<> dist_r(intervals, weights);
+ CHECK_SEQUENCE(dist_r.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(dist_r.densities(), list_of(.375)(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_linear_distribution<>
+ dist_r2(intervals2, weights2);
+ CHECK_SEQUENCE(dist_r2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(dist_r2.densities(), list_of(1.0)(1.0));
+
+ boost::random::piecewise_linear_distribution<> dist_it(
+ intervals.begin(), intervals.end(), weights.begin());
+ CHECK_SEQUENCE(dist_it.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(dist_it.densities(), list_of(.375)(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_linear_distribution<> dist_it2(
+ intervals2.begin(), intervals2.end(), weights2.begin());
+ CHECK_SEQUENCE(dist_it2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(dist_it2.densities(), list_of(1.0)(1.0));
+
+ boost::random::piecewise_linear_distribution<> dist_fun(4, 99,115, gen());
+ CHECK_SEQUENCE(dist_fun.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(dist_fun.densities(),
+ list_of(.09375)(.03125)(0.0625)(.03125)(.15625));
+
+ boost::random::piecewise_linear_distribution<>
+ dist_fun2(1, 99, 115, gen());
+ CHECK_SEQUENCE(dist_fun2.intervals(), list_of(99)(115));
+ CHECK_SEQUENCE(dist_fun2.densities(), list_of(0.046875)(0.078125));
+
+ boost::random::piecewise_linear_distribution<> copy(dist);
+ BOOST_CHECK_EQUAL(dist, copy);
+ boost::random::piecewise_linear_distribution<> copy_r(dist_r);
+ BOOST_CHECK_EQUAL(dist_r, copy_r);
+
+ boost::random::piecewise_linear_distribution<> notpow2(3, 99, 111, gen());
+ BOOST_REQUIRE_EQUAL(notpow2.densities().size(), 4u);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.densities()[0], 0.15, 1e-12);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.densities()[1], 0.05, 1e-12);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.densities()[2], 0.1, 1e-12);
+ BOOST_CHECK_CLOSE_FRACTION(notpow2.densities()[3], 0.05, 1e-12);
+ boost::random::piecewise_linear_distribution<> copy_notpow2(notpow2);
+ BOOST_CHECK_EQUAL(notpow2, copy_notpow2);
+}
+
+BOOST_AUTO_TEST_CASE(test_param) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(3)(1)(2)(1)(2);
+ std::vector<double> intervals2 = boost::assign::list_of(99);
+ std::vector<double> weights2 = boost::assign::list_of(2);
+ boost::random::piecewise_linear_distribution<> dist(intervals, weights);
+ boost::random::piecewise_linear_distribution<>::param_type
+ param = dist.param();
+ CHECK_SEQUENCE(param.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(param.densities(), list_of(.375)(.125)(.25)(.125)(.25));
+ boost::random::piecewise_linear_distribution<> copy1(param);
+ BOOST_CHECK_EQUAL(dist, copy1);
+ boost::random::piecewise_linear_distribution<> copy2;
+ copy2.param(param);
+ BOOST_CHECK_EQUAL(dist, copy2);
+
+ boost::random::piecewise_linear_distribution<>::param_type
+ param_copy = param;
+ BOOST_CHECK_EQUAL(param, param_copy);
+ BOOST_CHECK(param == param_copy);
+ BOOST_CHECK(!(param != param_copy));
+ boost::random::piecewise_linear_distribution<>::param_type param_default;
+ CHECK_SEQUENCE(param_default.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(param_default.densities(), list_of(1.0)(1.0));
+ BOOST_CHECK(param != param_default);
+ BOOST_CHECK(!(param == param_default));
+
+#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+ boost::random::piecewise_linear_distribution<>::param_type parm_il = {
+ { 99, 103, 107, 111, 115 },
+ gen()
+ };
+ CHECK_SEQUENCE(parm_il.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(parm_il.densities(),
+ list_of(.09375)(.03125)(0.0625)(.03125)(.15625));
+
+ boost::random::piecewise_linear_distribution<>::param_type parm_il2 = {
+ { 99 },
+ gen()
+ };
+ CHECK_SEQUENCE(parm_il2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(parm_il2.densities(), list_of(1.0)(1.0));
+#endif
+
+ boost::random::piecewise_linear_distribution<>::param_type
+ parm_r(intervals, weights);
+ CHECK_SEQUENCE(parm_r.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(parm_r.densities(), list_of(.375)(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_linear_distribution<>::param_type
+ parm_r2(intervals2, weights2);
+ CHECK_SEQUENCE(parm_r2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(parm_r2.densities(), list_of(1.0)(1.0));
+
+ boost::random::piecewise_linear_distribution<>::param_type
+ parm_it(intervals.begin(), intervals.end(), weights.begin());
+ CHECK_SEQUENCE(parm_it.intervals(), list_of(0)(1)(2)(3)(5));
+ CHECK_SEQUENCE(parm_it.densities(), list_of(.375)(.125)(.25)(.125)(.25));
+
+ boost::random::piecewise_linear_distribution<>::param_type
+ parm_it2(intervals2.begin(), intervals2.end(), weights2.begin());
+ CHECK_SEQUENCE(parm_it2.intervals(), list_of(0.0)(1.0));
+ CHECK_SEQUENCE(parm_it2.densities(), list_of(1.0)(1.0));
+
+ boost::random::piecewise_linear_distribution<>::param_type
+ parm_fun(4, 99, 115, gen());
+ CHECK_SEQUENCE(parm_fun.intervals(), list_of(99)(103)(107)(111)(115));
+ CHECK_SEQUENCE(parm_fun.densities(),
+ list_of(.09375)(.03125)(0.0625)(.03125)(.15625));
+
+ boost::random::piecewise_linear_distribution<>::param_type
+ parm_fun2(1, 99, 115, gen());
+ CHECK_SEQUENCE(parm_fun2.intervals(), list_of(99)(115));
+ CHECK_SEQUENCE(parm_fun2.densities(), list_of(0.046875)(0.078125));
+}
+
+BOOST_AUTO_TEST_CASE(test_min_max) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(3)(1)(2)(1)(2);
+ boost::random::piecewise_linear_distribution<> dist;
+ BOOST_CHECK_EQUAL((dist.min)(), 0.0);
+ BOOST_CHECK_EQUAL((dist.max)(), 1.0);
+ boost::random::piecewise_linear_distribution<> dist_r(intervals, weights);
+ BOOST_CHECK_EQUAL((dist_r.min)(), 0.0);
+ BOOST_CHECK_EQUAL((dist_r.max)(), 5.0);
+}
+
+BOOST_AUTO_TEST_CASE(test_comparison) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(3)(1)(2)(1)(2);
+ boost::random::piecewise_linear_distribution<> dist;
+ boost::random::piecewise_linear_distribution<> dist_copy(dist);
+ boost::random::piecewise_linear_distribution<> dist_r(intervals, weights);
+ boost::random::piecewise_linear_distribution<> dist_r_copy(dist_r);
+ BOOST_CHECK(dist == dist_copy);
+ BOOST_CHECK(!(dist != dist_copy));
+ BOOST_CHECK(dist_r == dist_r_copy);
+ BOOST_CHECK(!(dist_r != dist_r_copy));
+ BOOST_CHECK(dist != dist_r);
+ BOOST_CHECK(!(dist == dist_r));
+}
+
+BOOST_AUTO_TEST_CASE(test_streaming) {
+ std::vector<double> intervals = boost::assign::list_of(0)(1)(2)(3)(5);
+ std::vector<double> weights = boost::assign::list_of(3)(1)(2)(1)(2);
+ boost::random::piecewise_linear_distribution<> dist(intervals, weights);
+ std::stringstream stream;
+ stream << dist;
+ boost::random::piecewise_linear_distribution<> restored_dist;
+ stream >> restored_dist;
+ BOOST_CHECK_EQUAL(dist, restored_dist);
+}
+
+BOOST_AUTO_TEST_CASE(test_generation) {
+ std::vector<double> intervals = boost::assign::list_of(1)(2);
+ std::vector<double> weights = boost::assign::list_of(1)(1);
+ boost::minstd_rand0 gen;
+ boost::random::piecewise_linear_distribution<> dist;
+ boost::random::piecewise_linear_distribution<> dist_r(intervals, weights);
+ for(int i = 0; i < 10; ++i) {
+ double value = dist(gen);
+ BOOST_CHECK_GE(value, 0.0);
+ BOOST_CHECK_LT(value, 1.0);
+ double value_r = dist_r(gen);
+ BOOST_CHECK_GE(value_r, 1.0);
+ BOOST_CHECK_LT(value_r, 2.0);
+ double value_param = dist_r(gen, dist.param());
+ BOOST_CHECK_GE(value_param, 0.0);
+ BOOST_CHECK_LT(value_param, 1.0);
+ double value_r_param = dist(gen, dist_r.param());
+ BOOST_CHECK_GE(value_r_param, 1.0);
+ BOOST_CHECK_LT(value_r_param, 2.0);
+ }
+}
diff --git a/src/boost/libs/random/test/test_poisson.cpp b/src/boost/libs/random/test/test_poisson.cpp
new file mode 100644
index 000000000..519bf7e71
--- /dev/null
+++ b/src/boost/libs/random/test/test_poisson.cpp
@@ -0,0 +1,25 @@
+/* test_poisson.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/poisson_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/poisson.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::poisson_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME poisson
+#define BOOST_MATH_DISTRIBUTION boost::math::poisson
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME mean
+#define BOOST_RANDOM_ARG1_DEFAULT 100000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(1e-15, n)
+#define BOOST_RANDOM_DISTRIBUTION_MAX static_cast<int>(mean * 4)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_poisson_distribution.cpp b/src/boost/libs/random/test/test_poisson_distribution.cpp
new file mode 100644
index 000000000..a2cb5ae14
--- /dev/null
+++ b/src/boost/libs/random/test/test_poisson_distribution.cpp
@@ -0,0 +1,33 @@
+/* test_poisson_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/poisson_distribution.hpp>
+
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::poisson_distribution<>
+#define BOOST_RANDOM_ARG1 mean
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<int>::max)()
+#define BOOST_RANDOM_DIST1_MIN 0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<int>::max)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 10.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (1000.0)
+#define BOOST_RANDOM_TEST2_MIN 10.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_qrng_functions.hpp b/src/boost/libs/random/test/test_qrng_functions.hpp
new file mode 100644
index 000000000..effc96007
--- /dev/null
+++ b/src/boost/libs/random/test/test_qrng_functions.hpp
@@ -0,0 +1,278 @@
+// Copyright Justinas Vygintas Daugmaudis, 2010-2018.
+// Use, modification and distribution is subject to the
+// Boost Software License, Version 1.0. (See accompanying
+// file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
+
+#ifndef TEST_QRNG_FUNCTIONS_HPP_INCLUDED
+#define TEST_QRNG_FUNCTIONS_HPP_INCLUDED
+
+#include <boost/random/uniform_real.hpp>
+#include <boost/test/floating_point_comparison.hpp>
+
+#include <sstream>
+
+namespace test {
+
+// Invokes operator() precisely n times. This is to check that
+// Engine::discard(n) actually has the same effect.
+template<typename Engine>
+inline void trivial_discard(Engine& eng, boost::uintmax_t n)
+{
+ for( ; n != 0; --n ) eng();
+}
+
+
+template<typename Engine, typename T, std::size_t Dimension>
+inline void match_vector(Engine& eng, T (&pt)[Dimension])
+{
+ BOOST_REQUIRE_EQUAL( eng.dimension(), Dimension ); // paranoid check
+
+ boost::uniform_real<T> dist;
+
+ for( std::size_t i = 0; i != eng.dimension(); ++i )
+ {
+ T val = dist(eng);
+ // We want to check that quasi-random number generator values differ no
+ // more than 0.0006% of their value.
+ BOOST_CHECK_CLOSE(pt[i], val, 0.0006);
+ }
+}
+
+
+template<typename Engine, typename T, std::size_t Dimension, std::size_t N>
+inline void expected_values(T (&pt)[N][Dimension], std::size_t skip)
+{
+ Engine eng(Dimension);
+
+ eng.seed(skip);
+
+ for( std::size_t i = 0; i != N; ++i )
+ match_vector(eng, pt[i]);
+}
+
+template<typename Engine, typename T>
+inline void test_zero_seed(std::size_t dimension)
+{
+ Engine eng(dimension);
+
+ Engine other(dimension);
+ other.seed(0);
+
+ // Check that states are equal after zero seed.
+ boost::uniform_real<T> dist;
+ BOOST_CHECK( eng == other );
+ for( std:: size_t i = 0; i != dimension; ++i )
+ {
+ T q_val = dist(eng);
+ T t_val = dist(other);
+ BOOST_CHECK_CLOSE(q_val, t_val, 0.0001);
+ }
+}
+
+template<typename Engine, typename T, std::size_t Dimension, std::size_t N>
+inline void seed_function(T (&pt)[N][Dimension], std::size_t skip)
+{
+ // Test zero seed before doing other tests.
+ test_zero_seed<Engine, T>(Dimension);
+
+ Engine eng(Dimension);
+ for( std::size_t i = 0; i != N; ++i )
+ {
+ // For all N seeds an engine
+ // and checks if the expected values match.
+ eng.seed(skip + i);
+ match_vector(eng, pt[i]);
+ }
+}
+
+template<typename Engine, typename T, std::size_t Dimension, std::size_t N>
+inline void discard_function(T (&pt)[N][Dimension], std::size_t skip)
+{
+ Engine eng(Dimension), trivial(Dimension), streamed(Dimension), initial_state(Dimension);
+ boost::uniform_real<T> dist;
+
+ const std::size_t element_count = N * Dimension;
+ const T* pt_array = reinterpret_cast<T *>(boost::addressof(pt));
+
+ std::stringstream ss;
+
+ initial_state.seed(skip);
+ for (std::size_t step = 0; step != element_count; ++step)
+ {
+ // Init to the same state
+ eng = initial_state;
+ trivial = initial_state;
+
+ // Discards have to have the same effect
+ eng.discard(step);
+ trivial_discard(trivial, step);
+
+ // test serialization to stream
+ ss.str(std::string()); // clear stream
+ ss << eng;
+ ss >> streamed;
+
+ // Therefore, states are equal
+ BOOST_CHECK( eng == trivial );
+ BOOST_CHECK( eng == streamed );
+
+ // Now, let's check whether they really produce the same sequence
+ T q_val = dist(eng);
+ T t_val = dist(trivial);
+ T s_val = dist(streamed);
+ BOOST_CHECK_CLOSE(q_val, t_val, 0.0001);
+ BOOST_CHECK_CLOSE(q_val, s_val, 0.0001);
+ // ~ BOOST_CHECK(q_val == t_val), but those are floating point values,
+ // so strict equality check may fail unnecessarily
+
+ // States remain equal!
+ BOOST_CHECK( eng == trivial );
+ BOOST_CHECK( eng == streamed );
+
+ // We want to check that quasi-random number generator values differ no
+ // more than 0.0006% of their value.
+ BOOST_CHECK_CLOSE(pt_array[step], q_val, 0.0006);
+ }
+}
+
+inline bool accept_all_exceptions(const std::exception& e)
+{
+ BOOST_TEST_MESSAGE( e.what() );
+ return true;
+}
+
+template<typename Engine>
+void test_max_seed(std::size_t dim)
+{
+ typedef typename Engine::size_type size_type;
+ static const size_type maxseed = Engine::max();
+
+ Engine eng(dim);
+ eng.seed(maxseed-1); // must succeed
+ eng(); // skip one element
+ BOOST_REQUIRE_EXCEPTION( eng.seed(maxseed), std::range_error, accept_all_exceptions );
+
+ Engine other(dim);
+ other.seed(maxseed-1); // must succeed
+ other(); // skip one element, too
+
+ // States remain the same even after unsuccessful seeding for eng.
+ BOOST_CHECK( eng == other );
+ BOOST_CHECK( eng() == other() );
+}
+
+template<typename Generator>
+void test_max_discard(std::size_t dim)
+{
+ typedef typename Generator::type engine_type;
+
+ static const boost::uintmax_t maxdiscard = dim * engine_type::max();
+
+ // Max discard limit
+ {
+ engine_type eng(dim);
+ eng.discard(maxdiscard-1); // must succeed
+ eng(); // the very last element
+
+ BOOST_REQUIRE_EXCEPTION( eng(), std::range_error, accept_all_exceptions );
+
+ engine_type other(dim);
+
+ BOOST_CHECK( eng != other ); // test that comparison does not overflow
+
+ other(); // the very first element
+ other.discard(maxdiscard-1); // must succeed
+
+ BOOST_CHECK( eng == other );
+
+ BOOST_REQUIRE_EXCEPTION( other(), std::range_error, accept_all_exceptions );
+ }
+
+ // Overdiscarding
+ {
+ engine_type eng(dim);
+ eng.discard(maxdiscard); // must succeed, since it's maxdiscard operator() invocations
+
+ // must fail because after discarding the whole sequence
+ // we can't put the eng to any valid sequence producing state
+ BOOST_REQUIRE_EXCEPTION( eng(), std::range_error, accept_all_exceptions );
+
+ // Plain overdiscarding by 1
+ engine_type other(dim);
+ BOOST_REQUIRE_EXCEPTION( other.discard(maxdiscard+1), std::range_error, accept_all_exceptions );
+ }
+
+ // Test wraparound
+ {
+ engine_type eng(dim);
+
+ // must fail either because seq_count overflow check is triggered,
+ // or because this discard violates seeding bitcount constraint
+ BOOST_REQUIRE_EXCEPTION( eng.discard(maxdiscard*2), std::range_error, accept_all_exceptions );
+ }
+}
+
+} // namespace test
+
+
+#define QRNG_VALIDATION_TEST_FUNCTIONS(QRNG) \
+\
+typedef boost::random::QRNG engine_t; \
+\
+template<typename T, std::size_t Dimension, std::size_t N> \
+inline void test_##QRNG##_values(T (&pt)[N][Dimension], std::size_t skip) \
+{ \
+ test::expected_values<engine_t>(pt, skip); \
+} \
+\
+template<typename T, std::size_t Dimension, std::size_t N> \
+inline void test_##QRNG##_seed(T (&pt)[N][Dimension], std::size_t skip) \
+{ \
+ test::seed_function<engine_t>(pt, skip); \
+} \
+\
+template<typename T, std::size_t Dimension, std::size_t N> \
+inline void test_##QRNG##_discard(T (&pt)[N][Dimension], std::size_t skip) \
+{ \
+ test::discard_function<engine_t>(pt, skip); \
+} \
+inline void test_##QRNG##_max_seed() \
+{ \
+ test::test_max_seed<engine_t>(2); \
+} \
+inline void test_##QRNG##_max_dimension(std::size_t dim) \
+{ \
+ engine_t eng(dim); /*must succeed*/ \
+ BOOST_REQUIRE_EXCEPTION( engine_t(dim+1), std::invalid_argument, test::accept_all_exceptions ); \
+} \
+\
+BOOST_AUTO_TEST_CASE( test_##QRNG##_zero_dimension_fails ) \
+{ \
+ BOOST_REQUIRE_EXCEPTION( engine_t(0), std::invalid_argument, test::accept_all_exceptions ); \
+} \
+/**/
+
+#define QRNG_VALIDATION_TEST_DISCARD(QRNG) \
+\
+template <typename IntType, unsigned w> \
+struct gen_engine \
+{ \
+ typedef boost::random::QRNG##_engine<IntType, w> type; \
+}; \
+\
+inline void test_##QRNG##_max_discard() \
+{ \
+ static const std::size_t dim = 2;\
+ \
+ /* test full 8 bits */ \
+ test::test_max_discard<gen_engine<boost::uint8_t, 8u> >(dim); \
+ \
+ /* test 7 bits */ \
+ test::test_max_discard<gen_engine<boost::uint8_t, 7u> >(dim); \
+ \
+ /* test 6 bits for a good measure */ \
+ test::test_max_discard<gen_engine<boost::uint8_t, 6u> >(dim); \
+} \
+/**/
+
+#endif // TEST_QRNG_FUNCTIONS_HPP_INCLUDED
diff --git a/src/boost/libs/random/test/test_rand48.cpp b/src/boost/libs/random/test/test_rand48.cpp
new file mode 100644
index 000000000..79b61c13b
--- /dev/null
+++ b/src/boost/libs/random/test/test_rand48.cpp
@@ -0,0 +1,26 @@
+/* test_rand48.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/linear_congruential.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::rand48
+
+#define BOOST_RANDOM_SEED_WORDS 2
+
+// by experiment from lrand48()
+#define BOOST_RANDOM_VALIDATION_VALUE 1993516219U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 1286950069U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 839037874U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x55424A4U, 0x3A2CCEF5U, 0x6ADB4A65U, 0x2B019719U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_random_device.cpp b/src/boost/libs/random/test/test_random_device.cpp
new file mode 100644
index 000000000..2f9e61c76
--- /dev/null
+++ b/src/boost/libs/random/test/test_random_device.cpp
@@ -0,0 +1,29 @@
+/* boost random_test.cpp various tests
+ *
+ * Copyright (c) 2010 Steven Watanabe
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENCE_1_0.txt)
+ *
+ * $Id$
+ */
+
+#include <boost/random/random_device.hpp>
+
+#include <boost/test/test_tools.hpp>
+#include <boost/test/included/test_exec_monitor.hpp>
+
+int test_main(int, char**) {
+ boost::random_device rng;
+ double entropy = rng.entropy();
+ BOOST_CHECK_GE(entropy, 0);
+ for(int i = 0; i < 100; ++i) {
+ boost::random_device::result_type val = rng();
+ BOOST_CHECK_GE(val, (rng.min)());
+ BOOST_CHECK_LE(val, (rng.max)());
+ }
+
+ boost::uint32_t a[10];
+ rng.generate(a, a + 10);
+ return 0;
+}
diff --git a/src/boost/libs/random/test/test_random_number_generator.cpp b/src/boost/libs/random/test/test_random_number_generator.cpp
new file mode 100644
index 000000000..14add59cf
--- /dev/null
+++ b/src/boost/libs/random/test/test_random_number_generator.cpp
@@ -0,0 +1,35 @@
+/* boost test_random_number_generator.cpp
+ *
+ * Copyright Jens Maurer 2000
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ */
+
+#include <boost/random/random_number_generator.hpp>
+#include <boost/random/mersenne_twister.hpp>
+
+#include <algorithm>
+#include <vector>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+BOOST_AUTO_TEST_CASE(test_random_shuffle)
+{
+#ifndef BOOST_NO_CXX98_RANDOM_SHUFFLE
+ boost::mt19937 engine(1234);
+ boost::random::random_number_generator<boost::mt19937> generator(engine);
+
+ std::vector<int> testVec;
+
+ for (int i = 0; i < 200; ++i) {
+ testVec.push_back(i);
+ }
+
+ std::random_shuffle(testVec.begin(), testVec.end(), generator);
+#endif
+}
diff --git a/src/boost/libs/random/test/test_ranlux24.cpp b/src/boost/libs/random/test/test_ranlux24.cpp
new file mode 100644
index 000000000..34c9ba068
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux24.cpp
@@ -0,0 +1,26 @@
+/* test_ranlux24.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <cmath>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux24
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// validation from the C++0x draft (n3090)
+#define BOOST_RANDOM_VALIDATION_VALUE 9901578U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 10086048U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 3888733U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x55E57B2CU, 0xF2DEF915U, 0x6D1A0CD9U, 0xCA0109F9U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux24_base.cpp b/src/boost/libs/random/test/test_ranlux24_base.cpp
new file mode 100644
index 000000000..615ed1fc3
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux24_base.cpp
@@ -0,0 +1,25 @@
+/* test_ranlux24_base.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux24_base
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// validation from the C++0x draft (n3126).
+#define BOOST_RANDOM_VALIDATION_VALUE 7937952U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 14368281U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 7739608U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x55E57B2CU, 0xF2DEF915U, 0x6D1A0CD9U, 0xCA0109F9U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux3.cpp b/src/boost/libs/random/test/test_ranlux3.cpp
new file mode 100644
index 000000000..284cf5f13
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux3.cpp
@@ -0,0 +1,25 @@
+/* test_ranlux3.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux3
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE 5957620U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 11848780U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 11620328U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x55E57B2CU, 0xF2DEF915U, 0x6D1A0CD9U, 0xCA0109F9U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux3_01.cpp b/src/boost/libs/random/test/test_ranlux3_01.cpp
new file mode 100644
index 000000000..97b819802
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux3_01.cpp
@@ -0,0 +1,26 @@
+/* test_ranlux3_01.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <cmath>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux3_01
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE 5957620/std::pow(2.0f,24)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 11848780/std::pow(2.0f,24)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 11620328/std::pow(2.0f,24)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x55E57B2CU, 0xF2DEF915U, 0x6D1A0CD9U, 0xCA0109F9U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux4.cpp b/src/boost/libs/random/test/test_ranlux4.cpp
new file mode 100644
index 000000000..1ba17e943
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux4.cpp
@@ -0,0 +1,25 @@
+/* test_ranlux4.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux4
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE 8587295U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 10794046U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 4515722U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x55E57B2CU, 0xF2DEF915U, 0x6D1A0CD9U, 0xCA0109F9U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux48.cpp b/src/boost/libs/random/test/test_ranlux48.cpp
new file mode 100644
index 000000000..bd4fa092b
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux48.cpp
@@ -0,0 +1,26 @@
+/* test_ranlux48.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux48
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// validation from the C++0x draft (n3090)
+#define BOOST_RANDOM_VALIDATION_VALUE UINT64_C(249142670248501)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE UINT64_C(130319672235788)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE UINT64_C(154356577406237)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xFCE57B2CU, 0xF2DF1555U, 0x1A0C0CD9U, 0x490109FAU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux48_base.cpp b/src/boost/libs/random/test/test_ranlux48_base.cpp
new file mode 100644
index 000000000..3f5571312
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux48_base.cpp
@@ -0,0 +1,26 @@
+/* test_ranlux48_base.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <boost/cstdint.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux48_base
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// validation from the C++0x draft (n3126).
+#define BOOST_RANDOM_VALIDATION_VALUE UINT64_C(61839128582725)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE UINT64_C(15556320400833)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE UINT64_C(172853405006548)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xFCE57B2CU, 0xF2DF1555U, 0x1A0C0CD9U, 0x490109FAU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux4_01.cpp b/src/boost/libs/random/test/test_ranlux4_01.cpp
new file mode 100644
index 000000000..db1f6d944
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux4_01.cpp
@@ -0,0 +1,26 @@
+/* test_ranlux4_01.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <cmath>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux4_01
+
+#define BOOST_RANDOM_SEED_WORDS 24
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE 8587295/std::pow(2.0f,24)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 10794046/std::pow(2.0f,24)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 4515722/std::pow(2.0f,24)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x55E57B2CU, 0xF2DEF915U, 0x6D1A0CD9U, 0xCA0109F9U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux64_3.cpp b/src/boost/libs/random/test/test_ranlux64_3.cpp
new file mode 100644
index 000000000..0c9fbdec6
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux64_3.cpp
@@ -0,0 +1,27 @@
+/* test_ranlux64_3.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <boost/cstdint.hpp>
+#include <cmath>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux64_3
+
+#define BOOST_RANDOM_SEED_WORDS 48
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE UINT64_C(141789170949364)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE UINT64_C(85538657982635)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE UINT64_C(101724473226966)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xC35F616BU, 0xDC3C4DF1U, 0xF3F90D0AU, 0x206F9C9EU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux64_3_01.cpp b/src/boost/libs/random/test/test_ranlux64_3_01.cpp
new file mode 100644
index 000000000..9477677c5
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux64_3_01.cpp
@@ -0,0 +1,26 @@
+/* test_ranlux64_3_01.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <cmath>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux64_3_01
+
+#define BOOST_RANDOM_SEED_WORDS 48
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE INT64_C(141789170949364)/std::pow(2.0, 48)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE UINT64_C(85538657982635)/std::pow(2.0, 48)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE UINT64_C(101724473226966)/std::pow(2.0, 48)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xC35F616BU, 0xDC3C4DF1U, 0xF3F90D0AU, 0x206F9C9EU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux64_4.cpp b/src/boost/libs/random/test/test_ranlux64_4.cpp
new file mode 100644
index 000000000..df1c5427a
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux64_4.cpp
@@ -0,0 +1,27 @@
+/* test_ranlux64_4.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <boost/cstdint.hpp>
+#include <cmath>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux64_4
+
+#define BOOST_RANDOM_SEED_WORDS 48
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE UINT64_C(199461971133682)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE UINT64_C(160535400540538)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE UINT64_C(40074210927900)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xC35F616BU, 0xDC3C4DF1U, 0xF3F90D0AU, 0x206F9C9EU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_ranlux64_4_01.cpp b/src/boost/libs/random/test/test_ranlux64_4_01.cpp
new file mode 100644
index 000000000..1fb251d91
--- /dev/null
+++ b/src/boost/libs/random/test/test_ranlux64_4_01.cpp
@@ -0,0 +1,26 @@
+/* test_ranlux64_4_01.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/ranlux.hpp>
+#include <cmath>
+
+#define BOOST_RANDOM_URNG boost::random::ranlux64_4_01
+
+#define BOOST_RANDOM_SEED_WORDS 48
+
+// principal operation validated with CLHEP, values by experiment
+#define BOOST_RANDOM_VALIDATION_VALUE INT64_C(199461971133682)/std::pow(2.0, 48)
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE UINT64_C(160535400540538)/std::pow(2.0, 48)
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE UINT64_C(40074210927900)/std::pow(2.0, 48)
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0xC35F616BU, 0xDC3C4DF1U, 0xF3F90D0AU, 0x206F9C9EU }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_real_distribution.ipp b/src/boost/libs/random/test/test_real_distribution.ipp
new file mode 100644
index 000000000..478093989
--- /dev/null
+++ b/src/boost/libs/random/test/test_real_distribution.ipp
@@ -0,0 +1,195 @@
+/* test_real_distribution.ipp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#ifndef BOOST_MATH_DISTRIBUTION_INIT
+#ifdef BOOST_RANDOM_ARG2_TYPE
+#define BOOST_MATH_DISTRIBUTION_INIT (BOOST_RANDOM_ARG1_NAME, BOOST_RANDOM_ARG2_NAME)
+#else
+#define BOOST_MATH_DISTRIBUTION_INIT (BOOST_RANDOM_ARG1_NAME)
+#endif
+#endif
+
+#ifndef BOOST_RANDOM_DISTRIBUTION_INIT
+#ifdef BOOST_RANDOM_ARG2_TYPE
+#define BOOST_RANDOM_DISTRIBUTION_INIT (BOOST_RANDOM_ARG1_NAME, BOOST_RANDOM_ARG2_NAME)
+#else
+#define BOOST_RANDOM_DISTRIBUTION_INIT (BOOST_RANDOM_ARG1_NAME)
+#endif
+#endif
+
+#ifndef BOOST_RANDOM_P_CUTOFF
+#define BOOST_RANDOM_P_CUTOFF 0.99
+#endif
+
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/lexical_cast.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+#include <boost/preprocessor/stringize.hpp>
+#include <boost/range/numeric.hpp>
+#include <boost/numeric/conversion/cast.hpp>
+#include <iostream>
+#include <vector>
+
+#include "statistic_tests.hpp"
+#include "chi_squared_test.hpp"
+
+bool do_test(BOOST_RANDOM_ARG1_TYPE BOOST_RANDOM_ARG1_NAME,
+#ifdef BOOST_RANDOM_ARG2_TYPE
+ BOOST_RANDOM_ARG2_TYPE BOOST_RANDOM_ARG2_NAME,
+#endif
+ long long max, boost::mt19937& gen) {
+ std::cout << "running " BOOST_PP_STRINGIZE(BOOST_RANDOM_DISTRIBUTION_NAME) "("
+ << BOOST_RANDOM_ARG1_NAME;
+#ifdef BOOST_RANDOM_ARG2_NAME
+ std::cout << ", " << BOOST_RANDOM_ARG2_NAME;
+#endif
+ std::cout << ")" << " " << max << " times: " << std::flush;
+
+ BOOST_MATH_DISTRIBUTION expected BOOST_MATH_DISTRIBUTION_INIT;
+
+ BOOST_RANDOM_DISTRIBUTION dist BOOST_RANDOM_DISTRIBUTION_INIT;
+
+#ifdef BOOST_RANDOM_DISTRIBUTION_MAX
+
+ BOOST_RANDOM_DISTRIBUTION::result_type max_value = BOOST_RANDOM_DISTRIBUTION_MAX;
+
+ std::vector<double> expected_pdf(max_value+1);
+ {
+ for(int i = 0; i <= max_value; ++i) {
+ expected_pdf[i] = pdf(expected, i);
+ }
+ expected_pdf.back() += 1 - boost::accumulate(expected_pdf, 0.0);
+ }
+
+ std::vector<long long> results(max_value + 1);
+ for(long long i = 0; i < max; ++i) {
+ ++results[(std::min)(dist(gen), max_value)];
+ }
+
+ long long sum = boost::accumulate(results, 0ll);
+ if(sum != max) {
+ std::cout << "*** Failed: incorrect total: " << sum << " ***" << std::endl;
+ return false;
+ }
+ double prob = chi_squared_test(results, expected_pdf, max);
+
+#else
+
+ kolmogorov_experiment test(boost::numeric_cast<int>(max));
+ boost::variate_generator<boost::mt19937&, BOOST_RANDOM_DISTRIBUTION > vgen(gen, dist);
+
+ double prob = test.probability(test.run(vgen, expected));
+
+#endif
+
+ bool result = prob < BOOST_RANDOM_P_CUTOFF;
+ const char* err = result? "" : "*";
+ std::cout << std::setprecision(17) << prob << err << std::endl;
+
+ std::cout << std::setprecision(6);
+
+ return result;
+}
+
+template<class Dist1
+#ifdef BOOST_RANDOM_ARG2_NAME
+ , class Dist2
+#endif
+>
+bool do_tests(int repeat, Dist1 d1,
+#ifdef BOOST_RANDOM_ARG2_NAME
+ Dist2 d2,
+#endif
+ long long trials) {
+ boost::mt19937 gen;
+ int errors = 0;
+ for(int i = 0; i < repeat; ++i) {
+ if(!do_test(d1(gen),
+#ifdef BOOST_RANDOM_ARG2_NAME
+ d2(gen),
+#endif
+ trials, gen)) {
+ ++errors;
+ }
+ }
+ if(errors != 0) {
+ std::cout << "*** " << errors << " errors detected ***" << std::endl;
+ }
+ return errors == 0;
+}
+
+int usage() {
+ std::cerr << "Usage: test_" BOOST_PP_STRINGIZE(BOOST_RANDOM_DISTRIBUTION_NAME)
+ " -r <repeat>"
+ " -" BOOST_PP_STRINGIZE(BOOST_RANDOM_ARG1_NAME)
+ " <max " BOOST_PP_STRINGIZE(BOOST_RANDOM_ARG1_NAME) ">"
+#ifdef BOOST_RANDOM_ARG2_NAME
+ " -" BOOST_PP_STRINGIZE(BOOST_RANDOM_ARG2_NAME)
+ " <max " BOOST_PP_STRINGIZE(BOOST_RANDOM_ARG2_NAME) ">"
+#endif
+ " -t <trials>" << std::endl;
+ return 2;
+}
+
+template<class T>
+bool handle_option(int& argc, char**& argv, const char* opt, T& value) {
+ if(std::strcmp(argv[0], opt) == 0 && argc > 1) {
+ --argc;
+ ++argv;
+ value = boost::lexical_cast<T>(argv[0]);
+ return true;
+ } else {
+ return false;
+ }
+}
+
+int main(int argc, char** argv) {
+ int repeat = 1;
+ BOOST_RANDOM_ARG1_TYPE max_arg1 = BOOST_RANDOM_ARG1_DEFAULT;
+#ifdef BOOST_RANDOM_ARG2_TYPE
+ BOOST_RANDOM_ARG2_TYPE max_arg2 = BOOST_RANDOM_ARG2_DEFAULT;
+#endif
+ long long trials = 100000;
+
+ if(argc > 0) {
+ --argc;
+ ++argv;
+ }
+ while(argc > 0) {
+ if(argv[0][0] != '-') return usage();
+ else if(!handle_option(argc, argv, "-r", repeat)
+ && !handle_option(argc, argv, "-" BOOST_PP_STRINGIZE(BOOST_RANDOM_ARG1_NAME), max_arg1)
+#ifdef BOOST_RANDOM_ARG2_TYPE
+ && !handle_option(argc, argv, "-" BOOST_PP_STRINGIZE(BOOST_RANDOM_ARG2_NAME), max_arg2)
+#endif
+ && !handle_option(argc, argv, "-t", trials)) {
+ return usage();
+ }
+ --argc;
+ ++argv;
+ }
+
+ try {
+ if(do_tests(repeat,
+ BOOST_RANDOM_ARG1_DISTRIBUTION(max_arg1),
+#ifdef BOOST_RANDOM_ARG2_TYPE
+ BOOST_RANDOM_ARG2_DISTRIBUTION(max_arg2),
+#endif
+ trials)) {
+ return 0;
+ } else {
+ return EXIT_FAILURE;
+ }
+ } catch(...) {
+ std::cerr << boost::current_exception_diagnostic_information() << std::endl;
+ return EXIT_FAILURE;
+ }
+}
diff --git a/src/boost/libs/random/test/test_seed_seq.cpp b/src/boost/libs/random/test/test_seed_seq.cpp
new file mode 100644
index 000000000..c241d8027
--- /dev/null
+++ b/src/boost/libs/random/test/test_seed_seq.cpp
@@ -0,0 +1,130 @@
+/* boost test_seed_seq.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ */
+
+#include <boost/random/seed_seq.hpp>
+#include <boost/assign/list_of.hpp>
+#include <boost/config.hpp>
+#include <vector>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using boost::assign::list_of;
+
+BOOST_AUTO_TEST_CASE(test_seed_seq) {
+ boost::uint32_t expected_param[4] = { 2, 3, 4, 0xdeadbeaf };
+ boost::uint32_t param[4] = { 2, 3, 4, 0xdeadbeaf };
+ boost::uint32_t store32[10];
+ boost::uint64_t store64[10];
+ boost::uint32_t expected[10] = {
+ 3155793538u,
+ 2047427591u,
+ 2886057794u,
+ 280666868u,
+ 2184015838u,
+ 4035763234u,
+ 808987374u,
+ 3177165994u,
+ 2993445429u,
+ 3110180644u
+ };
+ std::fill_n(&store32[0], 10, 0);
+ std::fill_n(&store64[0], 10, 0);
+ boost::random::seed_seq seq;
+ seq.generate(&store32[0], &store32[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store32[0], &store32[0] + 10, &expected[0], &expected[0] + 10);
+ seq.generate(&store64[0], &store64[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store64[0], &store64[0] + 10, &expected[0], &expected[0] + 10);
+ BOOST_CHECK_EQUAL(seq.size(), 0u);
+ seq.param(&param[0]);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &param[0], &param[0] + 4, &expected_param[0], &expected_param[0] + 4);
+
+ boost::uint32_t expected_r[10] = {
+ 2681148375u,
+ 3302224839u,
+ 249244011u,
+ 1549723892u,
+ 3429166360u,
+ 2812310274u,
+ 3902694127u,
+ 1014283089u,
+ 1122383019u,
+ 494552679u
+ };
+
+ std::vector<int> data = list_of(2)(3)(4);
+
+ std::fill_n(&store32[0], 10, 0);
+ std::fill_n(&store64[0], 10, 0);
+ std::fill_n(&param[0], 3, 0);
+ boost::random::seed_seq seq_r(data);
+ seq_r.generate(&store32[0], &store32[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store32[0], &store32[0] + 10, &expected_r[0], &expected_r[0] + 10);
+ seq_r.generate(&store64[0], &store64[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store64[0], &store64[0] + 10, &expected_r[0], &expected_r[0] + 10);
+ BOOST_CHECK_EQUAL(seq_r.size(), 3u);
+ seq_r.param(&param[0]);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &param[0], &param[0] + 4, &expected_param[0], &expected_param[0] + 4);
+
+ std::fill_n(&store32[0], 10, 0);
+ std::fill_n(&store64[0], 10, 0);
+ std::fill_n(&param[0], 3, 0);
+ boost::random::seed_seq seq_it(data.begin(), data.end());
+ seq_it.generate(&store32[0], &store32[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store32[0], &store32[0] + 10, &expected_r[0], &expected_r[0] + 10);
+ seq_it.generate(&store64[0], &store64[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store64[0], &store64[0] + 10, &expected_r[0], &expected_r[0] + 10);
+ BOOST_CHECK_EQUAL(seq_it.size(), 3u);
+ seq_it.param(&param[0]);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &param[0], &param[0] + 4, &expected_param[0], &expected_param[0] + 4);
+
+#ifndef BOOST_NO_CXX11_HDR_INITIALIZER_LIST
+ std::fill_n(&store32[0], 10, 0);
+ std::fill_n(&store64[0], 10, 0);
+ std::fill_n(&param[0], 3, 0);
+ boost::random::seed_seq seq_il = {2, 3, 4};
+ seq_il.generate(&store32[0], &store32[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store32[0], &store32[0] + 10, &expected_r[0], &expected_r[0] + 10);
+ seq_il.generate(&store64[0], &store64[0] + 10);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store64[0], &store64[0] + 10, &expected_r[0], &expected_r[0] + 10);
+ BOOST_CHECK_EQUAL(seq_il.size(), 3u);
+ seq_il.param(&param[0]);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &param[0], &param[0] + 4, &expected_param[0], &expected_param[0] + 4);
+#endif
+}
+
+BOOST_AUTO_TEST_CASE(test_seed_seq_short_output) {
+ boost::uint32_t store32[2];
+
+ boost::uint32_t expected_short[2] = {
+ 4149590228u,
+ 3175758659u
+ };
+
+ std::vector<int> data = list_of(2)(3)(4)(5);
+
+ boost::random::seed_seq seq(data);
+
+ seq.generate(&store32[0], &store32[0] + 2);
+ BOOST_CHECK_EQUAL_COLLECTIONS(
+ &store32[0], &store32[0] + 2, &expected_short[0], &expected_short[0] + 2);
+}
diff --git a/src/boost/libs/random/test/test_student_t.cpp b/src/boost/libs/random/test/test_student_t.cpp
new file mode 100644
index 000000000..77f8221f5
--- /dev/null
+++ b/src/boost/libs/random/test/test_student_t.cpp
@@ -0,0 +1,24 @@
+/* test_student_t.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/student_t_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/students_t.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::student_t_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME student_t
+#define BOOST_MATH_DISTRIBUTION boost::math::students_t
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME n
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_student_t_distribution.cpp b/src/boost/libs/random/test/test_student_t_distribution.cpp
new file mode 100644
index 000000000..3602f6750
--- /dev/null
+++ b/src/boost/libs/random/test/test_student_t_distribution.cpp
@@ -0,0 +1,29 @@
+/* test_student_t_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/student_t_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::student_t_distribution<>
+#define BOOST_RANDOM_ARG1 n
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+
+#define BOOST_RANDOM_DIST0_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN -(std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+
+#define BOOST_RANDOM_TEST2_PARAMS (100.0)
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_taus88.cpp b/src/boost/libs/random/test/test_taus88.cpp
new file mode 100644
index 000000000..6e12f6168
--- /dev/null
+++ b/src/boost/libs/random/test/test_taus88.cpp
@@ -0,0 +1,24 @@
+/* test_taus88.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/taus88.hpp>
+
+#define BOOST_RANDOM_URNG boost::random::taus88
+
+#define BOOST_RANDOM_SEED_WORDS 3
+
+#define BOOST_RANDOM_VALIDATION_VALUE 3535848941U
+#define BOOST_RANDOM_SEED_SEQ_VALIDATION_VALUE 2562639222U
+#define BOOST_RANDOM_ITERATOR_VALIDATION_VALUE 3762466828U
+
+#define BOOST_RANDOM_GENERATE_VALUES { 0x2B55504U, 0x5403F102U, 0xED45297EU, 0x6B84007U }
+
+#include "test_generator.ipp"
diff --git a/src/boost/libs/random/test/test_triangle.cpp b/src/boost/libs/random/test/test_triangle.cpp
new file mode 100644
index 000000000..dda1b2f8c
--- /dev/null
+++ b/src/boost/libs/random/test/test_triangle.cpp
@@ -0,0 +1,26 @@
+/* test_triangle.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/triangle_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/triangular.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::triangle_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME lognormal
+#define BOOST_MATH_DISTRIBUTION boost::math::triangular
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME b
+#define BOOST_RANDOM_ARG1_DEFAULT 0.5
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.0001, 0.9999)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (0.0, b, 1.0)
+#define BOOST_MATH_DISTRIBUTION_INIT (0.0, b, 1.0)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_triangle_distribution.cpp b/src/boost/libs/random/test/test_triangle_distribution.cpp
new file mode 100644
index 000000000..32ded62c2
--- /dev/null
+++ b/src/boost/libs/random/test/test_triangle_distribution.cpp
@@ -0,0 +1,41 @@
+/* test_triangle_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/triangle_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::triangle_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG3 c
+#define BOOST_RANDOM_ARG1_DEFAULT 0.0
+#define BOOST_RANDOM_ARG2_DEFAULT 0.5
+#define BOOST_RANDOM_ARG3_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE -0.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+#define BOOST_RANDOM_ARG3_VALUE 1.5
+
+#define BOOST_RANDOM_DIST0_MIN 0.0
+#define BOOST_RANDOM_DIST0_MAX 1.0
+#define BOOST_RANDOM_DIST1_MIN -0.5
+#define BOOST_RANDOM_DIST1_MAX 1.0
+#define BOOST_RANDOM_DIST2_MIN -0.5
+#define BOOST_RANDOM_DIST2_MAX 1.0
+#define BOOST_RANDOM_DIST3_MIN -0.5
+#define BOOST_RANDOM_DIST3_MAX 1.5
+
+#define BOOST_RANDOM_TEST1_PARAMS (-1, -0.5, 0)
+#define BOOST_RANDOM_TEST1_MAX 0
+
+#define BOOST_RANDOM_TEST2_PARAMS (0, 0.5, 1)
+#define BOOST_RANDOM_TEST2_MIN 0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_uniform_int.cpp b/src/boost/libs/random/test/test_uniform_int.cpp
new file mode 100644
index 000000000..b1ccc0778
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_int.cpp
@@ -0,0 +1,27 @@
+/* test_uniform_int.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_int_distribution.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/math/distributions/uniform.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_int_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME uniform_int
+#define BOOST_MATH_DISTRIBUTION boost::math::uniform
+#define BOOST_RANDOM_ARG1_TYPE int
+#define BOOST_RANDOM_ARG1_NAME b
+#define BOOST_RANDOM_ARG1_DEFAULT 1000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_int<>(0, n)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (0, b)
+#define BOOST_MATH_DISTRIBUTION_INIT (0, b+1)
+#define BOOST_RANDOM_DISTRIBUTION_MAX b
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_uniform_int.ipp b/src/boost/libs/random/test/test_uniform_int.ipp
new file mode 100644
index 000000000..fe35c39a2
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_int.ipp
@@ -0,0 +1,149 @@
+/* boost test_uniform_int.ipp
+ *
+ * Copyright Jens Maurer 2000
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ */
+
+#include <numeric>
+#include <sstream>
+#include <vector>
+#include <boost/config.hpp>
+#include <boost/cstdint.hpp>
+#include <boost/limits.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
+#include <boost/random/variate_generator.hpp>
+#include "chi_squared_test.hpp"
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+template<class Generator>
+void check_uniform_int(Generator & gen, int iter)
+{
+ int range = (gen.max)()-(gen.min)()+1;
+ std::vector<int> bucket(range);
+ for(int j = 0; j < iter; j++) {
+ int result = gen();
+ BOOST_CHECK_GE(result, (gen.min)());
+ BOOST_CHECK_LE(result, (gen.max)());
+ if(result >= (gen.min)() && result <= (gen.max)()) {
+ bucket[result-(gen.min)()]++;
+ }
+ }
+ int sum = std::accumulate(bucket.begin(), bucket.end(), 0);
+ std::vector<double> expected(range, 1.0 / range);
+ BOOST_CHECK_LT(chi_squared_test(bucket, expected, sum), 0.99);
+}
+
+BOOST_AUTO_TEST_CASE(test_uniform_int)
+{
+ boost::random::mt19937 gen;
+ typedef BOOST_RANDOM_UNIFORM_INT<int> int_gen;
+
+ // large range => small range (modulo case)
+ typedef boost::random::variate_generator<boost::random::mt19937&, int_gen> level_one;
+
+ level_one uint12(gen, int_gen(1,2));
+ BOOST_CHECK((uint12.distribution().min)() == 1);
+ BOOST_CHECK((uint12.distribution().max)() == 2);
+ check_uniform_int(uint12, 100000);
+ level_one uint16(gen, int_gen(1,6));
+ check_uniform_int(uint16, 100000);
+
+ // test chaining to get all cases in operator()
+
+ // identity map
+ typedef boost::random::variate_generator<level_one&, int_gen> level_two;
+ level_two uint01(uint12, int_gen(0, 1));
+ check_uniform_int(uint01, 100000);
+
+ // small range => larger range
+ level_two uint05(uint12, int_gen(-3, 2));
+ check_uniform_int(uint05, 100000);
+
+ // small range => larger range
+ level_two uint099(uint12, int_gen(0, 99));
+ check_uniform_int(uint099, 100000);
+
+ // larger => small range, rejection case
+ typedef boost::random::variate_generator<level_two&, int_gen> level_three;
+ level_three uint1_4(uint05, int_gen(1, 4));
+ check_uniform_int(uint1_4, 100000);
+
+ typedef BOOST_RANDOM_UNIFORM_INT<boost::uint8_t> int8_gen;
+ typedef boost::random::variate_generator<boost::random::mt19937&, int8_gen> gen8_t;
+
+ gen8_t gen8_03(gen, int8_gen(0, 3));
+
+ // use the full range of the type, where the destination
+ // range is a power of the source range
+ typedef boost::random::variate_generator<gen8_t, int8_gen> uniform_uint8;
+ uniform_uint8 uint8_0255(gen8_03, int8_gen(0, 255));
+ check_uniform_int(uint8_0255, 100000);
+
+ // use the full range, but a generator whose range is not
+ // a root of the destination range.
+ gen8_t gen8_02(gen, int8_gen(0, 2));
+ uniform_uint8 uint8_0255_2(gen8_02, int8_gen(0, 255));
+ check_uniform_int(uint8_0255_2, 100000);
+
+ // expand the range to a larger type.
+ typedef boost::random::variate_generator<gen8_t, int_gen> uniform_uint_from8;
+ uniform_uint_from8 uint0300(gen8_03, int_gen(0, 300));
+ check_uniform_int(uint0300, 100000);
+}
+
+#if !defined(BOOST_NO_INT64_T) && !defined(BOOST_NO_INTEGRAL_INT64_T)
+
+// testcase by Mario Rutti
+class ruetti_gen
+{
+public:
+ ruetti_gen() : state((max)() - 1) {}
+ typedef boost::uint64_t result_type;
+ result_type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return 0; }
+ result_type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return std::numeric_limits<result_type>::max BOOST_PREVENT_MACRO_SUBSTITUTION (); }
+ result_type operator()() { return state--; }
+private:
+ result_type state;
+};
+
+BOOST_AUTO_TEST_CASE(test_overflow_range)
+{
+ ruetti_gen gen;
+ BOOST_RANDOM_DISTRIBUTION dist(0, 10);
+ for (int i=0;i<10;i++) {
+ dist(gen);
+ }
+}
+
+#endif
+
+BOOST_AUTO_TEST_CASE(test_misc)
+{
+ // bug report from Ken Mahler: This used to lead to an endless loop.
+ typedef BOOST_RANDOM_UNIFORM_INT<unsigned int> uint_dist;
+ boost::minstd_rand mr;
+ boost::variate_generator<boost::minstd_rand, uint_dist> r2(mr,
+ uint_dist(0, 0xffffffff));
+ r2();
+ r2();
+
+ // bug report from Fernando Cacciola: This used to lead to an endless loop.
+ // also from Douglas Gregor
+ boost::variate_generator<boost::minstd_rand, BOOST_RANDOM_DISTRIBUTION > x(mr, BOOST_RANDOM_DISTRIBUTION(0, 8361));
+ x();
+
+ // bug report from Alan Stokes and others: this throws an assertion
+ boost::variate_generator<boost::minstd_rand, BOOST_RANDOM_DISTRIBUTION > y(mr, BOOST_RANDOM_DISTRIBUTION(1,1));
+ y();
+ y();
+ y();
+}
diff --git a/src/boost/libs/random/test/test_uniform_int_distribution.cpp b/src/boost/libs/random/test/test_uniform_int_distribution.cpp
new file mode 100644
index 000000000..5863163b0
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_int_distribution.cpp
@@ -0,0 +1,42 @@
+/* test_uniform_int_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_int_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_int_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 0
+#define BOOST_RANDOM_ARG2_DEFAULT 0x7fffffff
+#define BOOST_RANDOM_ARG1_VALUE 100
+#define BOOST_RANDOM_ARG2_VALUE 250
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX 0x7fffffff
+#define BOOST_RANDOM_DIST1_MIN 100
+#define BOOST_RANDOM_DIST1_MAX 0x7fffffff
+#define BOOST_RANDOM_DIST2_MIN 100
+#define BOOST_RANDOM_DIST2_MAX 250
+
+#define BOOST_RANDOM_TEST1_PARAMS (0, 9)
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 9
+
+#define BOOST_RANDOM_TEST2_PARAMS (10, 19)
+#define BOOST_RANDOM_TEST2_MIN 10
+#define BOOST_RANDOM_TEST2_MAX 19
+
+#include "test_distribution.ipp"
+
+#define BOOST_RANDOM_UNIFORM_INT boost::random::uniform_int_distribution
+
+#include "test_uniform_int.ipp"
diff --git a/src/boost/libs/random/test/test_uniform_on_sphere.cpp b/src/boost/libs/random/test/test_uniform_on_sphere.cpp
new file mode 100644
index 000000000..4da940f5a
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_on_sphere.cpp
@@ -0,0 +1,45 @@
+/* test_uniform_on_sphere.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_on_sphere.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/math/distributions/uniform.hpp>
+#include <cmath>
+
+class uniform_on_sphere_test {
+public:
+ typedef double result_type;
+ uniform_on_sphere_test(int dims, int x, int y)
+ : impl(dims), idx1(x), idx2(y) {}
+ template<class Engine>
+ result_type operator()(Engine& rng) {
+ const boost::random::uniform_on_sphere<>::result_type& tmp = impl(rng);
+ // This should be uniformly distributed in [-pi,pi)
+ return std::atan2(tmp[idx1], tmp[idx2]);
+ }
+private:
+ boost::random::uniform_on_sphere<> impl;
+ int idx1, idx2;
+};
+
+static const double pi = 3.14159265358979323846;
+
+#define BOOST_RANDOM_DISTRIBUTION uniform_on_sphere_test
+#define BOOST_RANDOM_DISTRIBUTION_NAME uniform_on_sphere
+#define BOOST_MATH_DISTRIBUTION boost::math::uniform
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME n
+#define BOOST_RANDOM_ARG1_DEFAULT 6
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_int<>(2, n)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (n, 0, n-1)
+#define BOOST_MATH_DISTRIBUTION_INIT (-pi, pi)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_uniform_on_sphere_distribution.cpp b/src/boost/libs/random/test/test_uniform_on_sphere_distribution.cpp
new file mode 100644
index 000000000..2b966bccf
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_on_sphere_distribution.cpp
@@ -0,0 +1,87 @@
+/* test_uniform_on_sphere_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_on_sphere.hpp>
+#include <boost/assign/list_of.hpp>
+
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_on_sphere<>
+#define BOOST_RANDOM_ARG1 dim
+#define BOOST_RANDOM_ARG1_DEFAULT 2
+#define BOOST_RANDOM_ARG1_VALUE 3
+
+std::vector<double> min0 = boost::assign::list_of(-1.0)(0.0);
+std::vector<double> max0 = boost::assign::list_of(1.0)(0.0);
+std::vector<double> min1 = boost::assign::list_of(-1.0)(0.0)(0.0);
+std::vector<double> max1 = boost::assign::list_of(1.0)(0.0)(0.0);
+
+#define BOOST_RANDOM_DIST0_MIN min0
+#define BOOST_RANDOM_DIST0_MAX max0
+#define BOOST_RANDOM_DIST1_MIN min1
+#define BOOST_RANDOM_DIST1_MAX max1
+
+#define BOOST_RANDOM_TEST1_PARAMS (0)
+#define BOOST_RANDOM_TEST1_MIN std::vector<double>()
+#define BOOST_RANDOM_TEST1_MAX std::vector<double>()
+#define BOOST_RANDOM_TEST2_PARAMS
+#define BOOST_RANDOM_TEST2_MIN min0
+#define BOOST_RANDOM_TEST2_MAX max0
+
+#include <boost/test/test_tools.hpp>
+
+BOOST_TEST_DONT_PRINT_LOG_VALUE( std::vector<double> )
+
+#include "test_distribution.ipp"
+
+#include <boost/math/special_functions/fpclassify.hpp>
+
+struct generate_zeros {
+public:
+ generate_zeros() : i(0) {}
+ typedef unsigned result_type;
+ static unsigned (min)() { return 0u; }
+ static unsigned (max)() { return boost::random::minstd_rand0::max(); }
+ unsigned operator()() {
+ static unsigned data[] = { 0, 0, 0, 0, 0, 0 };
+ if(i < 6) {
+ return data[i++];
+ } else {
+ return gen();
+ }
+ }
+private:
+ int i;
+ boost::random::minstd_rand0 gen;
+};
+
+BOOST_AUTO_TEST_CASE(test_zeros) {
+ generate_zeros gen;
+ boost::random::uniform_on_sphere<> dist(2);
+ std::vector<double> val = dist(gen);
+ BOOST_CHECK(!(boost::math::isnan)(val[0]));
+}
+
+BOOST_AUTO_TEST_CASE(test_valid_output) {
+ boost::random::minstd_rand0 gen;
+ for(int n = 0; n < 10; ++n) {
+ boost::random::uniform_on_sphere<> dist(n);
+ std::vector<double> result = dist(gen);
+ BOOST_TEST(result.size() == static_cast<std::size_t>(n));
+ if(n > 0) {
+ double sum_sq = 0;
+ for(std::size_t j = 0; j < result.size(); ++j) {
+ sum_sq += result[j] * result[j];
+ }
+ BOOST_CHECK_CLOSE_FRACTION(sum_sq, 1.0, 1e-5);
+ }
+ }
+}
diff --git a/src/boost/libs/random/test/test_uniform_real.cpp b/src/boost/libs/random/test/test_uniform_real.cpp
new file mode 100644
index 000000000..a920fd657
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_real.cpp
@@ -0,0 +1,26 @@
+/* test_uniform_real.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_real_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/uniform.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_real_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME uniform_int
+#define BOOST_MATH_DISTRIBUTION boost::math::uniform
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME b
+#define BOOST_RANDOM_ARG1_DEFAULT 1000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0, n)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (0, b)
+#define BOOST_MATH_DISTRIBUTION_INIT (0, b)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_uniform_real_distribution.cpp b/src/boost/libs/random/test/test_uniform_real_distribution.cpp
new file mode 100644
index 000000000..ed47e59e7
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_real_distribution.cpp
@@ -0,0 +1,48 @@
+/* test_uniform_real_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_real_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_real_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 0.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE -0.5
+#define BOOST_RANDOM_ARG2_VALUE 1.5
+
+#define BOOST_RANDOM_DIST0_MIN 0.0
+#define BOOST_RANDOM_DIST0_MAX 1.0
+#define BOOST_RANDOM_DIST1_MIN -0.5
+#define BOOST_RANDOM_DIST1_MAX 1.0
+#define BOOST_RANDOM_DIST2_MIN -0.5
+#define BOOST_RANDOM_DIST2_MAX 1.5
+
+#define BOOST_RANDOM_TEST1_PARAMS (-1.0, 0.0)
+#define BOOST_RANDOM_TEST1_MIN -1.0
+#define BOOST_RANDOM_TEST1_MAX 0.0
+
+#define BOOST_RANDOM_TEST2_PARAMS
+#define BOOST_RANDOM_TEST2_MIN 0.0
+#define BOOST_RANDOM_TEST2_MAX 1.0
+
+#include "test_distribution.ipp"
+
+BOOST_AUTO_TEST_CASE(test_dbl_min_max) {
+ boost::random::minstd_rand rng;
+ double min = -(std::numeric_limits<double>::max)();
+ double max = (std::numeric_limits<double>::max)();
+ boost::random::uniform_real_distribution<double> dist(min, max);
+ double val = dist(rng);
+ BOOST_CHECK_GE(val, min);
+ BOOST_CHECK_LE(val, max);
+}
diff --git a/src/boost/libs/random/test/test_uniform_smallint.cpp b/src/boost/libs/random/test/test_uniform_smallint.cpp
new file mode 100644
index 000000000..4950079f0
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_smallint.cpp
@@ -0,0 +1,27 @@
+/* test_uniform_smallint.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_smallint.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/math/distributions/uniform.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_smallint<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME uniform_int
+#define BOOST_MATH_DISTRIBUTION boost::math::uniform
+#define BOOST_RANDOM_ARG1_TYPE int
+#define BOOST_RANDOM_ARG1_NAME b
+#define BOOST_RANDOM_ARG1_DEFAULT 1000
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_int<>(0, n)
+#define BOOST_RANDOM_DISTRIBUTION_INIT (0, b)
+#define BOOST_MATH_DISTRIBUTION_INIT (0, b+1)
+#define BOOST_RANDOM_DISTRIBUTION_MAX b
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_uniform_smallint_distribution.cpp b/src/boost/libs/random/test/test_uniform_smallint_distribution.cpp
new file mode 100644
index 000000000..d943ebfb2
--- /dev/null
+++ b/src/boost/libs/random/test/test_uniform_smallint_distribution.cpp
@@ -0,0 +1,38 @@
+/* test_uniform_smallint_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2011
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/uniform_smallint.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::uniform_smallint<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 0
+#define BOOST_RANDOM_ARG2_DEFAULT 9
+#define BOOST_RANDOM_ARG1_VALUE 5
+#define BOOST_RANDOM_ARG2_VALUE 250
+
+#define BOOST_RANDOM_DIST0_MIN 0
+#define BOOST_RANDOM_DIST0_MAX 9
+#define BOOST_RANDOM_DIST1_MIN 5
+#define BOOST_RANDOM_DIST1_MAX 9
+#define BOOST_RANDOM_DIST2_MIN 5
+#define BOOST_RANDOM_DIST2_MAX 250
+
+#define BOOST_RANDOM_TEST1_PARAMS (0, 9)
+#define BOOST_RANDOM_TEST1_MIN 0
+#define BOOST_RANDOM_TEST1_MAX 9
+
+#define BOOST_RANDOM_TEST2_PARAMS (10, 19)
+#define BOOST_RANDOM_TEST2_MIN 10
+#define BOOST_RANDOM_TEST2_MAX 19
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_weibull.cpp b/src/boost/libs/random/test/test_weibull.cpp
new file mode 100644
index 000000000..1319cf041
--- /dev/null
+++ b/src/boost/libs/random/test/test_weibull.cpp
@@ -0,0 +1,28 @@
+/* test_weibull.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+
+#include <boost/random/weibull_distribution.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/math/distributions/weibull.hpp>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::weibull_distribution<>
+#define BOOST_RANDOM_DISTRIBUTION_NAME weibull
+#define BOOST_MATH_DISTRIBUTION boost::math::weibull
+#define BOOST_RANDOM_ARG1_TYPE double
+#define BOOST_RANDOM_ARG1_NAME a
+#define BOOST_RANDOM_ARG1_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG1_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+#define BOOST_RANDOM_ARG2_TYPE double
+#define BOOST_RANDOM_ARG2_NAME b
+#define BOOST_RANDOM_ARG2_DEFAULT 1000.0
+#define BOOST_RANDOM_ARG2_DISTRIBUTION(n) boost::uniform_real<>(0.00001, n)
+
+#include "test_real_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_weibull_distribution.cpp b/src/boost/libs/random/test/test_weibull_distribution.cpp
new file mode 100644
index 000000000..cd88b6d5f
--- /dev/null
+++ b/src/boost/libs/random/test/test_weibull_distribution.cpp
@@ -0,0 +1,36 @@
+/* test_weibull_distribution.cpp
+ *
+ * Copyright Steven Watanabe 2010
+ * Distributed under the Boost Software License, Version 1.0. (See
+ * accompanying file LICENSE_1_0.txt or copy at
+ * http://www.boost.org/LICENSE_1_0.txt)
+ *
+ * $Id$
+ *
+ */
+#include <boost/random/weibull_distribution.hpp>
+#include <limits>
+
+#define BOOST_RANDOM_DISTRIBUTION boost::random::weibull_distribution<>
+#define BOOST_RANDOM_ARG1 a
+#define BOOST_RANDOM_ARG2 b
+#define BOOST_RANDOM_ARG1_DEFAULT 1.0
+#define BOOST_RANDOM_ARG2_DEFAULT 1.0
+#define BOOST_RANDOM_ARG1_VALUE 7.5
+#define BOOST_RANDOM_ARG2_VALUE 0.25
+
+#define BOOST_RANDOM_DIST0_MIN 0.0
+#define BOOST_RANDOM_DIST0_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST1_MIN 0.0
+#define BOOST_RANDOM_DIST1_MAX (std::numeric_limits<double>::infinity)()
+#define BOOST_RANDOM_DIST2_MIN 0.0
+#define BOOST_RANDOM_DIST2_MAX (std::numeric_limits<double>::infinity)()
+
+#define BOOST_RANDOM_TEST1_PARAMS
+#define BOOST_RANDOM_TEST1_MIN 0.0
+#define BOOST_RANDOM_TEST1_MAX 100.0
+
+#define BOOST_RANDOM_TEST2_PARAMS (1.0, 1000000.0)
+#define BOOST_RANDOM_TEST2_MIN 100.0
+
+#include "test_distribution.ipp"
diff --git a/src/boost/libs/random/test/test_zero_seed.cpp b/src/boost/libs/random/test/test_zero_seed.cpp
new file mode 100644
index 000000000..983f395ba
--- /dev/null
+++ b/src/boost/libs/random/test/test_zero_seed.cpp
@@ -0,0 +1,29 @@
+/*
+ Test case for ticket #7951
+ tests whether or not xxx() == xxx(0) for various engines
+ Thanks to Stephen T. Lavavej for his close reading of 26.5.3.3 [rand.eng.sub]/7
+*/
+
+#include <boost/random/ranlux.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/mersenne_twister.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#ifdef BOOST_MSVC
+#pragma warning(push)
+#pragma warning(disable:4244)
+#endif
+
+BOOST_AUTO_TEST_CASE(test_zero_seed)
+{
+ BOOST_CHECK(boost::random::ranlux24_base(0) == boost::random::ranlux24_base());
+ BOOST_CHECK(boost::random::minstd_rand0(0) == boost::random::minstd_rand0());
+ BOOST_CHECK(boost::random::mt19937(0) != boost::random::mt19937());
+
+ BOOST_CHECK(boost::random::ranlux48_base(0) == boost::random::ranlux48_base ());
+
+ BOOST_CHECK(boost::random::ranlux_base_01(0) == boost::random::ranlux_base_01 ());
+ BOOST_CHECK(boost::random::ranlux64_base_01(0) == boost::random::ranlux64_base_01 ());
+}