MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
test_normal_dist.cpp File Reference
#include <iostream>
#include <map>
#include <iomanip>
#include "Distributions.h"
#include "../utility/testing_macros.hpp"
+ Include dependency graph for test_normal_dist.cpp:

Go to the source code of this file.

Functions

int main (int argc, const char *argv[])
 
int test_normal_dist ()
 

Function Documentation

int main ( int  argc,
const char *  argv[] 
)

Definition at line 59 of file test_normal_dist.cpp.

References test_normal_dist().

60 {
62  return 0;
63 }
int test_normal_dist()

+ Here is the call graph for this function:

int test_normal_dist ( )

Definition at line 26 of file test_normal_dist.cpp.

References ASSERT_DOUBLE_EQ.

Referenced by main().

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 }
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
#define ASSERT_DOUBLE_EQ(token, a, b)
std::random_device MOOSE_RANDOM_DEVICE
Definition: Definitions.h:29

+ Here is the caller graph for this function: