1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // REQUIRES: long_tests
14 // template<class RealType = double>
15 // class cauchy_distribution
17 // template<class _URNG> result_type operator()(_URNG& g);
25 f(double x, double a, double b)
27 return 1/3.1415926535897932 * std::atan((x - a)/b) + .5;
33 typedef std::cauchy_distribution<> D;
34 typedef std::mt19937 G;
39 const int N = 1000000;
40 std::vector<D::result_type> u;
41 for (int i = 0; i < N; ++i)
43 std::sort(u.begin(), u.end());
44 for (int i = 0; i < N; ++i)
45 assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
48 typedef std::cauchy_distribution<> D;
49 typedef std::mt19937 G;
51 const double a = -1.5;
54 const int N = 1000000;
55 std::vector<D::result_type> u;
56 for (int i = 0; i < N; ++i)
58 std::sort(u.begin(), u.end());
59 for (int i = 0; i < N; ++i)
60 assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);
63 typedef std::cauchy_distribution<> D;
64 typedef std::mt19937 G;
69 const int N = 1000000;
70 std::vector<D::result_type> u;
71 for (int i = 0; i < N; ++i)
73 std::sort(u.begin(), u.end());
74 for (int i = 0; i < N; ++i)
75 assert(std::abs(f(u[i], a, b) - double(i)/N) < .001);