random_number_generator.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10  ** Includes
11  *****************************************************************************/
12 
13 #include <iostream>
14 #include "../../include/ecl/time/random_number_generator.hpp"
15 
16 /*****************************************************************************
17  ** Main
18  *****************************************************************************/
19 
20 int main()
21 {
22 
23  ecl::RandomNumberGenerator<float> random_number_generator;
24  int n = 5;
25 
26  std::cout << std::endl;
27  std::cout << "***********************************************************" << std::endl;
28  std::cout << " Uniform Numbers" << std::endl;
29  std::cout << "***********************************************************" << std::endl;
30  std::cout << std::endl;
31 
32  std::cout << "Default (0, 1):" << std::endl;
33  for (int i = 0; i < n; ++i)
34  {
35  std::cout << " " << random_number_generator.uniform();
36  }
37  std::cout << std::endl;
38  for (int i = 0; i < n; ++i)
39  {
40  std::cout << " " << random_number_generator.uniform();
41  }
42  std::cout << std::endl;
43  std::cout << "Over Range (-5, 5): " << std::endl;
44  for (int i = 0; i < n; ++i)
45  {
46  std::cout << " " << random_number_generator.uniform(5.0);
47  }
48  std::cout << std::endl;
49  for (int i = 0; i < n; ++i)
50  {
51  std::cout << " " << random_number_generator.uniform(5.0);
52  }
53  std::cout << std::endl;
54 
55  std::cout << std::endl;
56  std::cout << "***********************************************************" << std::endl;
57  std::cout << " Guassian" << std::endl;
58  std::cout << "***********************************************************" << std::endl;
59  std::cout << std::endl;
60 
61  std::cout << "std = 1, avg = 0: " << std::endl;
62  for (int i = 0; i < n; ++i)
63  {
64  std::cout << " " << random_number_generator.gaussian(1.0);
65  }
66  std::cout << std::endl;
67  for (int i = 0; i < n; ++i)
68  {
69  std::cout << " " << random_number_generator.gaussian(1.0);
70  }
71  std::cout << std::endl;
72 
73  std::cout << "std = 1, avg = 3: " << std::endl;
74  for (int i = 0; i < n; ++i)
75  {
76  std::cout << " " << random_number_generator.gaussian(1.0, 3.0);
77  }
78  std::cout << std::endl;
79  for (int i = 0; i < n; ++i)
80  {
81  std::cout << " " << random_number_generator.gaussian(1.0, 3.0);
82  }
83  std::cout << std::endl;
84 
85  std::cout << "std = 3, avg = 5: " << std::endl;
86  for (int i = 0; i < n; ++i)
87  {
88  std::cout << " " << random_number_generator.gaussian(3.0, 5.0);
89  }
90  std::cout << std::endl;
91  for (int i = 0; i < n; ++i)
92  {
93  std::cout << " " << random_number_generator.gaussian(3.0, 5.0);
94  }
95  std::cout << std::endl;
96 
97  std::cout << std::endl;
98  std::cout << "***********************************************************" << std::endl;
99  std::cout << " Passed" << std::endl;
100  std::cout << "***********************************************************" << std::endl;
101  std::cout << std::endl;
102  return 0;
103 }
A random number generator.
T gaussian(const T &std, const T &mu=0)


ecl_time
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:15