source: issm/trunk-jpl/src/c/shared/Random/randomgenerator.h@ 26616

Last change on this file since 26616 was 26616, checked in by bulthuis, 3 years ago

CGH: add lognormal, chi-squared, and exponential distributions to pseudo-random generator

  • Property svn:executable set to *
File size: 2.3 KB
Line 
1/*!\file: randomgenerator.h
2 * \brief prototypes for randomgenerator.h
3 */
4
5#ifndef _RANDOMGENERATOR_H_
6#define _RANDOMGENERATOR_H_
7
8#undef M_PI
9#define M_PI 3.141592653589793238462643
10
11namespace rnd{
12
13 class linear_congruential_engine
14 {
15 private:
16 unsigned int a;
17 unsigned int c;
18 unsigned int m;
19 unsigned int *pseed;
20
21 public:
22
23 /*constructors, destructors: */
24 linear_congruential_engine();
25 linear_congruential_engine(unsigned int _a, unsigned int _b, unsigned int _m);
26 ~linear_congruential_engine();
27
28 unsigned int get_m();
29 void seed( int s );
30 unsigned int generator();
31
32 };
33
34 class uniform_distribution
35 {
36
37 private:
38 double a; // lower bound of range
39 double b; // upper bound of range
40
41 public:
42
43 /*constructors, destructors: */
44 uniform_distribution();
45 uniform_distribution(double _a,double _b);
46 ~uniform_distribution();
47
48 double generator(rnd::linear_congruential_engine random_engine);
49
50 };
51
52 class normal_distribution
53 {
54
55 private:
56 double mean;
57 double sdev;
58
59 public:
60
61 /*constructors, destructors: */
62 normal_distribution();
63 normal_distribution(double m,double s);
64 ~normal_distribution();
65
66 double generator(rnd::linear_congruential_engine random_engine);
67
68 };
69
70 class lognormal_distribution
71 {
72
73 private:
74 double logmean;
75 double logsdev;
76
77 public:
78
79 /*constructors, destructors: */
80 lognormal_distribution();
81 lognormal_distribution(double m,double s);
82 ~lognormal_distribution();
83
84 double generator(rnd::linear_congruential_engine random_engine);
85
86 };
87
88 class chi_squared_distribution
89 {
90
91 private:
92 unsigned int k;
93
94 public:
95
96 /*constructors, destructors: */
97 chi_squared_distribution();
98 chi_squared_distribution(unsigned int k);
99 ~chi_squared_distribution();
100
101 double generator(rnd::linear_congruential_engine random_engine);
102
103 };
104
105 class exponential_distribution
106 {
107
108 private:
109 double lambda;
110
111 public:
112
113 /*constructors, destructors: */
114 exponential_distribution();
115 exponential_distribution(double scale);
116 ~exponential_distribution();
117
118 double generator(rnd::linear_congruential_engine random_engine);
119
120 };
121
122
123}
124
125#endif //* _RANDOMGENERATOR_H_ */
Note: See TracBrowser for help on using the repository browser.