MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
test_normal_dist.cpp
Go to the documentation of this file.
1 /***
2  * Filename: test_normal_dist.cpp
3  *
4  * Description: test script.
5  *
6  * Version: 0.0.1
7  * Created: 2018-08-04
8 
9  * Revision: none
10  *
11  * Author: Dilawar Singh <dilawars@ncbs.res.in>
12  * Organization: NCBS Bangalore
13  *
14  * License: GNU GPL2
15  */
16 
17 
18 #include <iostream>
19 #include <map>
20 #include <iomanip>
21 
22 #include "Distributions.h"
23 #include "../utility/testing_macros.hpp"
24 
25 
27 {
28 
31  gen.seed( 10 );
32 
34 
35  std::map<int, int> hist{};
36  std::vector<double> dist;
37  for(int n=0; n<100000; ++n)
38  {
39  double x = d(gen);
40  dist.push_back( x );
41  ++hist[ std::round(x) ];
42  }
43 
44  for(auto p : hist) {
45  std::cout << std::setw(2)
46  << p.first << ' ' << std::string(p.second/200, '*') << '\n';
47  }
48 
49  ASSERT_DOUBLE_EQ( "NORMALDIST", hist[-3], 542 );
50  ASSERT_DOUBLE_EQ( "NORMALDIST", hist[-2], 5987 );
51  ASSERT_DOUBLE_EQ( "NORMALDIST", hist[-1], 24262 );
52  ASSERT_DOUBLE_EQ( "NORMALDIST", hist[0], 38236 );
53  ASSERT_DOUBLE_EQ( "NORMALDIST", hist[1], 24386 );
54  ASSERT_DOUBLE_EQ( "NORMALDIST", hist[2], 6071 );
55 
56  return 0;
57 }
58 
59 int main(int argc, const char *argv[])
60 {
62  return 0;
63 }
std::mersenne_twister_engine< std::uint_fast32_t, 32, 624, 397, 31, 0x9908b0df, 11, 0xffffffff, 7, 0x9d2c5680, 15, 0xefc60000, 18, 1812433253 > MOOSE_RNG_DEFAULT_ENGINE
Definition: Definitions.h:42
int main(int argc, const char *argv[])
#define ASSERT_DOUBLE_EQ(token, a, b)
std::random_device MOOSE_RANDOM_DEVICE
Definition: Definitions.h:29
int test_normal_dist()