summaryrefslogtreecommitdiff
path: root/random-example.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'random-example.cpp')
-rw-r--r--random-example.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/random-example.cpp b/random-example.cpp
new file mode 100644
index 0000000..484bc6f
--- /dev/null
+++ b/random-example.cpp
@@ -0,0 +1,36 @@
+#include <iostream>
+#include <random>
+
+using namespace std;
+
+int main()
+{
+ const int iterations = 1000;
+
+ mt19937 gen;
+ normal_distribution<double> norm(5.0,2.0);
+ exponential_distribution<double> expo(3.5);
+ negative_binomial_distribution<int> negbin(3,0.5);
+ uniform_int_distribution<int> uint(0,9);
+ uniform_real_distribution<double> ureal(0.0,5.0);
+
+
+ cout << "x\t"
+ << "normal\t"
+ << "exponential\t"
+ << "Neg-Binomial\t"
+ << "Unif-Int\t"
+ << "Unif-Real"
+ << endl;
+
+ for (int i=0;i<iterations;++i) {
+ cout << (i+1) << "\t"
+ << norm(gen) << "\t"
+ << expo(gen) << "\t"
+ << negbin(gen) << "\t"
+ << uint(gen) << "\t"
+ << ureal(gen) << "\t"
+ << endl;
+ }
+ return 0;
+}