diff options
Diffstat (limited to 'libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin')
18 files changed, 0 insertions, 1172 deletions
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp deleted file mode 100644 index 82473d2883b..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/assign.pass.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// binomial_distribution& operator=(const binomial_distribution&); - -#include <random> -#include <cassert> - -void -test1() -{ - typedef std::binomial_distribution<> D; - D d1(2, 0.75); - D d2; - assert(d1 != d2); - d2 = d1; - assert(d1 == d2); -} - -int main() -{ - test1(); -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp deleted file mode 100644 index 71549488678..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/copy.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// binomial_distribution(const binomial_distribution&); - -#include <random> -#include <cassert> - -void -test1() -{ - typedef std::binomial_distribution<> D; - D d1(2, 0.75); - D d2 = d1; - assert(d1 == d2); -} - -int main() -{ - test1(); -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp deleted file mode 100644 index 5a3a22eeebd..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_int_double.pass.cpp +++ /dev/null @@ -1,40 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// explicit binomial_distribution(IntType t = 1, double p = 0.5); - -#include <random> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - D d; - assert(d.t() == 1); - assert(d.p() == 0.5); - } - { - typedef std::binomial_distribution<> D; - D d(3); - assert(d.t() == 3); - assert(d.p() == 0.5); - } - { - typedef std::binomial_distribution<> D; - D d(3, 0.75); - assert(d.t() == 3); - assert(d.p() == 0.75); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp deleted file mode 100644 index cfb98f2985e..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/ctor_param.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// explicit binomial_distribution(const param_type& parm); - -#include <random> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type P; - P p(5, 0.25); - D d(p); - assert(d.t() == 5); - assert(d.p() == 0.25); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp deleted file mode 100644 index 738bdc80e93..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eq.pass.cpp +++ /dev/null @@ -1,43 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// bool operator=(const binomial_distribution& x, -// const binomial_distribution& y); -// bool operator!(const binomial_distribution& x, -// const binomial_distribution& y); - -#include <random> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - D d1(3, .25); - D d2(3, .25); - assert(d1 == d2); - } - { - typedef std::binomial_distribution<> D; - D d1(3, .28); - D d2(3, .25); - assert(d1 != d2); - } - { - typedef std::binomial_distribution<> D; - D d1(3, .25); - D d2(4, .25); - assert(d1 != d2); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp deleted file mode 100644 index 43c6b546bdb..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval.pass.cpp +++ /dev/null @@ -1,475 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// REQUIRES: long_tests - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// template<class _URNG> result_type operator()(_URNG& g); - -#include <random> -#include <numeric> -#include <vector> -#include <cassert> - -template <class T> -inline -T -sqr(T x) -{ - return x * x; -} - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef std::mt19937_64 G; - G g; - D d(5, .75); - const int N = 1000000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); - double x_skew = (1-2*d.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs((skew - x_skew) / x_skew) < 0.01); - assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(30, .03125); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); - double x_skew = (1-2*d.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs((skew - x_skew) / x_skew) < 0.01); - assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(40, .25); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); - double x_skew = (1-2*d.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs((skew - x_skew) / x_skew) < 0.03); - assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(40, 0); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - // In this case: - // skew computes to 0./0. == nan - // kurtosis computes to 0./0. == nan - // x_skew == inf - // x_kurtosis == inf - // These tests are commented out because UBSan warns about division by 0 -// skew /= u.size() * dev * var; -// kurtosis /= u.size() * var * var; -// kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); -// double x_skew = (1-2*d.p()) / std::sqrt(x_var); -// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(mean == x_mean); - assert(var == x_var); -// assert(skew == x_skew); -// assert(kurtosis == x_kurtosis); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(40, 1); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - // In this case: - // skew computes to 0./0. == nan - // kurtosis computes to 0./0. == nan - // x_skew == -inf - // x_kurtosis == inf - // These tests are commented out because UBSan warns about division by 0 -// skew /= u.size() * dev * var; -// kurtosis /= u.size() * var * var; -// kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); -// double x_skew = (1-2*d.p()) / std::sqrt(x_var); -// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(mean == x_mean); - assert(var == x_var); -// assert(skew == x_skew); -// assert(kurtosis == x_kurtosis); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(400, 0.5); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); - double x_skew = (1-2*d.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs(skew - x_skew) < 0.01); - assert(std::abs(kurtosis - x_kurtosis) < 0.01); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(1, 0.5); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); - double x_skew = (1-2*d.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs(skew - x_skew) < 0.01); - assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); - } - { - const int N = 100000; - std::mt19937 gen1; - std::mt19937 gen2; - - std::binomial_distribution<> dist1(5, 0.1); - std::binomial_distribution<unsigned> dist2(5, 0.1); - - for(int i = 0; i < N; ++i) - assert(dist1(gen1) == dist2(gen2)); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(0, 0.005); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - // In this case: - // skew computes to 0./0. == nan - // kurtosis computes to 0./0. == nan - // x_skew == inf - // x_kurtosis == inf - // These tests are commented out because UBSan warns about division by 0 -// skew /= u.size() * dev * var; -// kurtosis /= u.size() * var * var; -// kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); -// double x_skew = (1-2*d.p()) / std::sqrt(x_var); -// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(mean == x_mean); - assert(var == x_var); -// assert(skew == x_skew); -// assert(kurtosis == x_kurtosis); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(0, 0); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - // In this case: - // skew computes to 0./0. == nan - // kurtosis computes to 0./0. == nan - // x_skew == inf - // x_kurtosis == inf - // These tests are commented out because UBSan warns about division by 0 -// skew /= u.size() * dev * var; -// kurtosis /= u.size() * var * var; -// kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); -// double x_skew = (1-2*d.p()) / std::sqrt(x_var); -// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(mean == x_mean); - assert(var == x_var); -// assert(skew == x_skew); -// assert(kurtosis == x_kurtosis); - } - { - typedef std::binomial_distribution<> D; - typedef std::mt19937 G; - G g; - D d(0, 1); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g); - assert(d.min() <= v && v <= d.max()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - // In this case: - // skew computes to 0./0. == nan - // kurtosis computes to 0./0. == nan - // x_skew == -inf - // x_kurtosis == inf - // These tests are commented out because UBSan warns about division by 0 -// skew /= u.size() * dev * var; -// kurtosis /= u.size() * var * var; -// kurtosis -= 3; - double x_mean = d.t() * d.p(); - double x_var = x_mean*(1-d.p()); -// double x_skew = (1-2*d.p()) / std::sqrt(x_var); -// double x_kurtosis = (1-6*d.p()*(1-d.p())) / x_var; - assert(mean == x_mean); - assert(var == x_var); -// assert(skew == x_skew); -// assert(kurtosis == x_kurtosis); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp deleted file mode 100644 index 1aa66ed57ad..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/eval_param.pass.cpp +++ /dev/null @@ -1,160 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// REQUIRES: long_tests - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm); - -#include <random> -#include <numeric> -#include <vector> -#include <cassert> - -template <class T> -inline -T -sqr(T x) -{ - return x * x; -} - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type P; - typedef std::mt19937_64 G; - G g; - D d(16, .75); - P p(5, .75); - const int N = 1000000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g, p); - assert(0 <= v && v <= p.t()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = p.t() * p.p(); - double x_var = x_mean*(1-p.p()); - double x_skew = (1-2*p.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs((skew - x_skew) / x_skew) < 0.01); - assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.04); - } - { - typedef std::binomial_distribution<> D; - typedef D::param_type P; - typedef std::mt19937 G; - G g; - D d(16, .75); - P p(30, .03125); - const int N = 100000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g, p); - assert(0 <= v && v <= p.t()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = p.t() * p.p(); - double x_var = x_mean*(1-p.p()); - double x_skew = (1-2*p.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs((skew - x_skew) / x_skew) < 0.01); - assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.01); - } - { - typedef std::binomial_distribution<> D; - typedef D::param_type P; - typedef std::mt19937 G; - G g; - D d(16, .75); - P p(40, .25); - const int N = 1000000; - std::vector<D::result_type> u; - for (int i = 0; i < N; ++i) - { - D::result_type v = d(g, p); - assert(0 <= v && v <= p.t()); - u.push_back(v); - } - double mean = std::accumulate(u.begin(), u.end(), - double(0)) / u.size(); - double var = 0; - double skew = 0; - double kurtosis = 0; - for (int i = 0; i < u.size(); ++i) - { - double d = (u[i] - mean); - double d2 = sqr(d); - var += d2; - skew += d * d2; - kurtosis += d2 * d2; - } - var /= u.size(); - double dev = std::sqrt(var); - skew /= u.size() * dev * var; - kurtosis /= u.size() * var * var; - kurtosis -= 3; - double x_mean = p.t() * p.p(); - double x_var = x_mean*(1-p.p()); - double x_skew = (1-2*p.p()) / std::sqrt(x_var); - double x_kurtosis = (1-6*p.p()*(1-p.p())) / x_var; - assert(std::abs((mean - x_mean) / x_mean) < 0.01); - assert(std::abs((var - x_var) / x_var) < 0.01); - assert(std::abs((skew - x_skew) / x_skew) < 0.04); - assert(std::abs((kurtosis - x_kurtosis) / x_kurtosis) < 0.3); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp deleted file mode 100644 index 88c8424b093..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/get_param.pass.cpp +++ /dev/null @@ -1,29 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// param_type param() const; - -#include <random> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type P; - P p(5, .125); - D d(p); - assert(d.param() == p); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp deleted file mode 100644 index 1276454b597..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/io.pass.cpp +++ /dev/null @@ -1,41 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// template <class charT, class traits> -// basic_ostream<charT, traits>& -// operator<<(basic_ostream<charT, traits>& os, -// const binomial_distribution& x); -// -// template <class charT, class traits> -// basic_istream<charT, traits>& -// operator>>(basic_istream<charT, traits>& is, -// binomial_distribution& x); - -#include <random> -#include <sstream> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - D d1(7, .25); - std::ostringstream os; - os << d1; - std::istringstream is(os.str()); - D d2; - is >> d2; - assert(d1 == d2); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp deleted file mode 100644 index 9c88faabe60..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/max.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// result_type max() const; - -#include <random> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - D d(4, .25); - assert(d.max() == 4); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp deleted file mode 100644 index 678a34b2f54..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/min.pass.cpp +++ /dev/null @@ -1,27 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// result_type min() const; - -#include <random> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - D d(4, .5); - assert(d.min() == 0); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp deleted file mode 100644 index 553f8ad8268..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_assign.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution -// { -// class param_type; - -#include <random> -#include <limits> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - param_type p0(6, .7); - param_type p; - p = p0; - assert(p.t() == 6); - assert(p.p() == .7); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp deleted file mode 100644 index a9770efa282..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_copy.pass.cpp +++ /dev/null @@ -1,31 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution -// { -// class param_type; - -#include <random> -#include <limits> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - param_type p0(10, .125); - param_type p = p0; - assert(p.t() == 10); - assert(p.p() == .125); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp deleted file mode 100644 index cadf84a8904..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_ctor.pass.cpp +++ /dev/null @@ -1,44 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution -// { -// class param_type; - -#include <random> -#include <limits> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - param_type p; - assert(p.t() == 1); - assert(p.p() == 0.5); - } - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - param_type p(10); - assert(p.t() == 10); - assert(p.p() == 0.5); - } - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - param_type p(10, 0.25); - assert(p.t() == 10); - assert(p.p() == 0.25); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp deleted file mode 100644 index 3c2c1faa5c1..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_eq.pass.cpp +++ /dev/null @@ -1,37 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution -// { -// class param_type; - -#include <random> -#include <limits> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - param_type p1(3, 0.75); - param_type p2(3, 0.75); - assert(p1 == p2); - } - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - param_type p1(3, 0.75); - param_type p2(3, 0.5); - assert(p1 != p2); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp deleted file mode 100644 index 6c745611cd4..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/param_types.pass.cpp +++ /dev/null @@ -1,28 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution -// { -// class param_type; - -#include <random> -#include <type_traits> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type param_type; - typedef param_type::distribution_type distribution_type; - static_assert((std::is_same<D, distribution_type>::value), ""); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp deleted file mode 100644 index 612f5e2def0..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/set_param.pass.cpp +++ /dev/null @@ -1,30 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution - -// void param(const param_type& parm); - -#include <random> -#include <cassert> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::param_type P; - P p(10, 0.25); - D d(8, 0.75); - d.param(p); - assert(d.param() == p); - } -} diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp deleted file mode 100644 index 0e71aa019e7..00000000000 --- a/libcxx/test/numerics/rand/rand.dis/rand.dist.bern/rand.dist.bern.bin/types.pass.cpp +++ /dev/null @@ -1,32 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <random> - -// template<class IntType = int> -// class binomial_distribution -// { -// typedef bool result_type; - -#include <random> -#include <type_traits> - -int main() -{ - { - typedef std::binomial_distribution<> D; - typedef D::result_type result_type; - static_assert((std::is_same<result_type, int>::value), ""); - } - { - typedef std::binomial_distribution<long> D; - typedef D::result_type result_type; - static_assert((std::is_same<result_type, long>::value), ""); - } -} |

