summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-05-17 18:31:53 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-05-17 18:31:53 +0000
commitfd5c3a34e3cd5f0556f597b2aec201bca1b101cf (patch)
treef432dc64b2b6d4a8c222f37c5060c889edc9852c /libcxx/test
parentc9a99c5e5cb65462c34b9c4312820ad9cc6ac8a3 (diff)
downloadbcm5719-llvm-fd5c3a34e3cd5f0556f597b2aec201bca1b101cf.tar.gz
bcm5719-llvm-fd5c3a34e3cd5f0556f597b2aec201bca1b101cf.zip
[rand.dist.norm.lognormal]
llvm-svn: 103957
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp34
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp32
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp40
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp30
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp37
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp242
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp248
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp29
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp41
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp28
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp27
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp32
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp31
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp44
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp37
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp28
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp30
-rw-r--r--libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp34
18 files changed, 1024 insertions, 0 deletions
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp
new file mode 100644
index 00000000000..01e897bf369
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/assign.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution& operator=(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::lognormal_distribution<> D;
+ D d1(20, 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.norm/rand.dist.norm.lognormal/copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp
new file mode 100644
index 00000000000..574e8871028
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/copy.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// lognormal_distribution(const lognormal_distribution&);
+
+#include <random>
+#include <cassert>
+
+void
+test1()
+{
+ typedef std::lognormal_distribution<> D;
+ D d1(20, 1.75);
+ D d2 = d1;
+ assert(d1 == d2);
+}
+
+int main()
+{
+ test1();
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp
new file mode 100644
index 00000000000..1d2eafac6f5
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_double_double.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(result_type mean = 0, result_type stddev = 1);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d;
+ assert(d.m() == 0);
+ assert(d.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(14.5);
+ assert(d.m() == 14.5);
+ assert(d.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(14.5, 5.25);
+ assert(d.m() == 14.5);
+ assert(d.s() == 5.25);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp
new file mode 100644
index 00000000000..1011fdb9d9b
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/ctor_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// explicit lognormal_distribution(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 10);
+ D d(p);
+ assert(d.m() == 0.25);
+ assert(d.s() == 10);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp
new file mode 100644
index 00000000000..bb253c18692
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// bool operator=(const lognormal_distribution& x,
+// const lognormal_distribution& y);
+// bool operator!(const lognormal_distribution& x,
+// const lognormal_distribution& y);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4);
+ assert(d1 == d2);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(2.5, 4);
+ D d2(2.5, 4.5);
+ assert(d1 != d2);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
new file mode 100644
index 00000000000..4779eb6ca0a
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval.pass.cpp
@@ -0,0 +1,242 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./8192, 0.015625);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ 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.05);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.25);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./32, 0.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ 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.03);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-1./8, 0.5);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ 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.02);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.05);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.02);
+ assert(std::abs(skew - x_skew) / x_skew < 0.08);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.4);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(-0.78125, 1.25);
+ const int N = 1000000;
+ std::vector<D::result_type> u;
+ for (int i = 0; i < N; ++i)
+ {
+ D::result_type v = d(g);
+ assert(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(d.m() + sqr(d.s())/2);
+ double x_var = (std::exp(sqr(d.s())) - 1) * std::exp(2*d.m() + sqr(d.s()));
+ double x_skew = (std::exp(sqr(d.s())) + 2) *
+ std::sqrt((std::exp(sqr(d.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(d.s())) + 2*std::exp(3*sqr(d.s())) +
+ 3*std::exp(2*sqr(d.s())) - 6;
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.04);
+ assert(std::abs(skew - x_skew) / x_skew < 0.2);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.7);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
new file mode 100644
index 00000000000..27909b4f567
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/eval_param.pass.cpp
@@ -0,0 +1,248 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template<class _URNG> result_type operator()(_URNG& g, const param_type& parm);
+
+#include <random>
+#include <cassert>
+#include <vector>
+#include <numeric>
+
+template <class T>
+inline
+T
+sqr(T x)
+{
+ return x * x;
+}
+
+int main()
+{
+
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./8192, 0.015625);
+ 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(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ 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.05);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.25);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./32, 0.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(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ 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.03);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-1./8, 0.5);
+ 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(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ 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.02);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.05);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d(3, 4);
+ P p;
+ 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(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.02);
+ assert(std::abs(skew - x_skew) / x_skew < 0.08);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.4);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ typedef std::mt19937 G;
+ G g;
+ D d;
+ P p(-0.78125, 1.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(v > 0);
+ u.push_back(v);
+ }
+ double mean = std::accumulate(u.begin(), u.end(), 0.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 = std::exp(p.m() + sqr(p.s())/2);
+ double x_var = (std::exp(sqr(p.s())) - 1) * std::exp(2*p.m() + sqr(p.s()));
+ double x_skew = (std::exp(sqr(p.s())) + 2) *
+ std::sqrt((std::exp(sqr(p.s())) - 1));
+ double x_kurtosis = std::exp(4*sqr(p.s())) + 2*std::exp(3*sqr(p.s())) +
+ 3*std::exp(2*sqr(p.s())) - 6;
+ assert(std::abs(mean - x_mean) / x_mean < 0.01);
+ assert(std::abs(var - x_var) / x_var < 0.04);
+ assert(std::abs(skew - x_skew) / x_skew < 0.2);
+ assert(std::abs(kurtosis - x_kurtosis) / x_kurtosis < 0.7);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp
new file mode 100644
index 00000000000..e8737bb8365
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/get_param.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// param_type param() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(.125, .5);
+ D d(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp
new file mode 100644
index 00000000000..ed690d5b00f
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/io.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// template <class CharT, class Traits, class RealType>
+// basic_ostream<CharT, Traits>&
+// operator<<(basic_ostream<CharT, Traits>& os,
+// const lognormal_distribution<RealType>& x);
+
+// template <class CharT, class Traits, class RealType>
+// basic_istream<CharT, Traits>&
+// operator>>(basic_istream<CharT, Traits>& is,
+// lognormal_distribution<RealType>& x);
+
+#include <random>
+#include <sstream>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d1(7, 5);
+ 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.norm/rand.dist.norm.lognormal/max.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp
new file mode 100644
index 00000000000..6cb7ed2c1a2
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/max.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type max() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(5, .25);
+ D::result_type m = d.max();
+ assert(m == INFINITY);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp
new file mode 100644
index 00000000000..cd565ac357d
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/min.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+
+// result_type min() const;
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ D d(.5, .5);
+ assert(d.min() == 0);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp
new file mode 100644
index 00000000000..ac387424159
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_assign.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(.75, 6);
+ param_type p;
+ p = p0;
+ assert(p.m() == .75);
+ assert(p.s() == 6);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp
new file mode 100644
index 00000000000..cd63934250d
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_copy.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p0(10, .125);
+ param_type p = p0;
+ assert(p.m() == 10);
+ assert(p.s() == .125);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp
new file mode 100644
index 00000000000..58be96e8a80
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_ctor.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p;
+ assert(p.m() == 0);
+ assert(p.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10);
+ assert(p.m() == 10);
+ assert(p.s() == 1);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p(10, 5);
+ assert(p.m() == 10);
+ assert(p.s() == 5);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp
new file mode 100644
index 00000000000..2beb5782698
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_eq.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <limits>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.75, .5);
+ assert(p1 == p2);
+ }
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type param_type;
+ param_type p1(0.75, .5);
+ param_type p2(0.5, .5);
+ assert(p1 != p2);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp
new file mode 100644
index 00000000000..1c5a44299c9
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/param_types.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// class param_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::lognormal_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.norm/rand.dist.norm.lognormal/set_param.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp
new file mode 100644
index 00000000000..e0f7660cf4e
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/set_param.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution;
+
+// void param(const param_type& parm);
+
+#include <random>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::param_type P;
+ P p(0.25, 5.5);
+ D d(0.75, 4);
+ d.param(p);
+ assert(d.param() == p);
+ }
+}
diff --git a/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp
new file mode 100644
index 00000000000..25504f038dd
--- /dev/null
+++ b/libcxx/test/numerics/rand/rand.dis/rand.dist.norm/rand.dist.norm.lognormal/types.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <random>
+
+// template<class RealType = double>
+// class lognormal_distribution
+// {
+// public:
+// // types
+// typedef RealType result_type;
+
+#include <random>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef std::lognormal_distribution<> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, double>::value), "");
+ }
+ {
+ typedef std::lognormal_distribution<float> D;
+ typedef D::result_type result_type;
+ static_assert((std::is_same<result_type, float>::value), "");
+ }
+}
OpenPOWER on IntegriCloud