diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:45:20 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2016-03-21 15:46:37 +0900 |
commit | 733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch) | |
tree | a5b214744b256f07e1dc2bd7273035a7808c659f /libs/random | |
parent | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff) | |
download | boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.gz boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.bz2 boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.zip |
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94
Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'libs/random')
-rw-r--r-- | libs/random/doc/Jamfile.v2 | 4 | ||||
-rw-r--r-- | libs/random/doc/distributions.qbk | 1 | ||||
-rw-r--r-- | libs/random/doc/random.qbk | 1 | ||||
-rw-r--r-- | libs/random/meta/libraries.json | 17 | ||||
-rw-r--r-- | libs/random/test/Jamfile.v2 | 2 | ||||
-rw-r--r-- | libs/random/test/test_generator.ipp | 37 | ||||
-rw-r--r-- | libs/random/test/test_mt11213b.cpp | 2 | ||||
-rw-r--r-- | libs/random/test/test_mt19937.cpp | 3 | ||||
-rw-r--r-- | libs/random/test/test_mt19937_64.cpp | 2 | ||||
-rw-r--r-- | libs/random/test/test_non_central_chi_squared.cpp | 29 | ||||
-rw-r--r-- | libs/random/test/test_non_central_chi_squared_distribution.cpp | 39 |
11 files changed, 135 insertions, 2 deletions
diff --git a/libs/random/doc/Jamfile.v2 b/libs/random/doc/Jamfile.v2 index 88f4c6eb42..a3607fc83b 100644 --- a/libs/random/doc/Jamfile.v2 +++ b/libs/random/doc/Jamfile.v2 @@ -14,6 +14,8 @@ import regex ; import os ; import path ; +path-constant here : . ; + doxygen_files = additive_combine bernoulli_distribution @@ -37,6 +39,7 @@ doxygen_files = lognormal_distribution mersenne_twister negative_binomial_distribution + non_central_chi_squared_distribution normal_distribution piecewise_constant_distribution piecewise_linear_distribution @@ -168,4 +171,5 @@ boostbook standalone : <implicit-dependency>reference <xsl:param>boost.root=../../../.. <xsl:param>chunk.section.depth=2 + <format>pdf:<xsl:param>img.src.path=$(here)/html/ ; diff --git a/libs/random/doc/distributions.qbk b/libs/random/doc/distributions.qbk index a6624df7b0..d94b1cd857 100644 --- a/libs/random/doc/distributions.qbk +++ b/libs/random/doc/distributions.qbk @@ -85,6 +85,7 @@ statistically to it are not acceptable. [measuring the job completion time of an assembly line worker]] [[__chi_squared_distribution][chi-squared distribution][-]] + [[__non_central_chi_squared_distribution][non-central chi-squared distribution][-]] [[__cauchy_distribution][Cauchy distribution][-]] [[__fisher_f_distribution][Fisher F distribution][-]] [[__student_t_distribution][Student t distribution][-]] diff --git a/libs/random/doc/random.qbk b/libs/random/doc/random.qbk index 9dd53da4b6..5b25a7afef 100644 --- a/libs/random/doc/random.qbk +++ b/libs/random/doc/random.qbk @@ -88,6 +88,7 @@ [def __student_t_distribution [classref boost::random::student_t_distribution student_t_distribution]] [def __fisher_f_distribution [classref boost::random::fisher_f_distribution fisher_f_distribution]] [def __chi_squared_distribution [classref boost::random::chi_squared_distribution chi_squared_distribution]] +[def __non_central_chi_squared_distribution [classref boost::random::non_central_chi_squared_distribution non_central_chi_squared_distribution]] [def __piecewise_constant_distribution [classref boost::random::piecewise_constant_distribution piecewise_constant_distribution]] [def __piecewise_linear_distribution [classref boost::random::piecewise_linear_distribution piecewise_linear_distribution]] diff --git a/libs/random/meta/libraries.json b/libs/random/meta/libraries.json new file mode 100644 index 0000000000..ffdd91ca42 --- /dev/null +++ b/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/libs/random/test/Jamfile.v2 b/libs/random/test/Jamfile.v2 index 50373b6b55..6055e06727 100644 --- a/libs/random/test/Jamfile.v2 +++ b/libs/random/test/Jamfile.v2 @@ -119,6 +119,8 @@ 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 nondet_random_speed.cpp ; # run random_device.cpp ; diff --git a/libs/random/test/test_generator.ipp b/libs/random/test/test_generator.ipp index 16c7b0bb4a..bd57bdd591 100644 --- a/libs/random/test/test_generator.ipp +++ b/libs/random/test/test_generator.ipp @@ -26,6 +26,10 @@ typedef boost::random::detail::seed_type<result_type>::type seed_type; #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) { @@ -157,13 +161,42 @@ BOOST_AUTO_TEST_CASE(test_discard) BOOST_RANDOM_URNG urng; BOOST_RANDOM_URNG urng2; BOOST_CHECK_EQUAL(urng, urng2); - for(int i = 0; i < 9307; ++i) + for(int i = 0; i < BOOST_RANDOM_DISCARD_COUNT1; ++i) urng(); BOOST_CHECK_NE(urng, urng2); - urng2.discard(9307); + 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; diff --git a/libs/random/test/test_mt11213b.cpp b/libs/random/test/test_mt11213b.cpp index a0ad81d544..62e2644f6d 100644 --- a/libs/random/test/test_mt11213b.cpp +++ b/libs/random/test/test_mt11213b.cpp @@ -18,6 +18,8 @@ #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 } diff --git a/libs/random/test/test_mt19937.cpp b/libs/random/test/test_mt19937.cpp index bbd37bbf6e..ca699b23ba 100644 --- a/libs/random/test/test_mt19937.cpp +++ b/libs/random/test/test_mt19937.cpp @@ -22,6 +22,9 @@ #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 } diff --git a/libs/random/test/test_mt19937_64.cpp b/libs/random/test/test_mt19937_64.cpp index 9800c1e968..e3300847b5 100644 --- a/libs/random/test/test_mt19937_64.cpp +++ b/libs/random/test/test_mt19937_64.cpp @@ -20,6 +20,8 @@ #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 } diff --git a/libs/random/test/test_non_central_chi_squared.cpp b/libs/random/test/test_non_central_chi_squared.cpp new file mode 100644 index 0000000000..914b7752ec --- /dev/null +++ b/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/libs/random/test/test_non_central_chi_squared_distribution.cpp b/libs/random/test/test_non_central_chi_squared_distribution.cpp new file mode 100644 index 0000000000..0c88134aa9 --- /dev/null +++ b/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" |