[26554] | 1 | /*!\file: randomgenerator.h
|
---|
| 2 | * \brief prototypes for randomgenerator.h
|
---|
| 3 | */
|
---|
[26598] | 4 |
|
---|
| 5 | #ifndef _RANDOMGENERATOR_H_
|
---|
| 6 | #define _RANDOMGENERATOR_H_
|
---|
| 7 |
|
---|
| 8 | #undef M_PI
|
---|
| 9 | #define M_PI 3.141592653589793238462643
|
---|
| 10 |
|
---|
[26603] | 11 | namespace rnd{
|
---|
[26598] | 12 |
|
---|
[26612] | 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();
|
---|
[26656] | 31 | void free_resources();
|
---|
[26612] | 32 | };
|
---|
| 33 |
|
---|
[26603] | 34 | class uniform_distribution
|
---|
| 35 | {
|
---|
[26598] | 36 |
|
---|
[26603] | 37 | private:
|
---|
[26612] | 38 | double a; // lower bound of range
|
---|
| 39 | double b; // upper bound of range
|
---|
[26598] | 40 |
|
---|
[26603] | 41 | public:
|
---|
[26598] | 42 |
|
---|
[26603] | 43 | /*constructors, destructors: */
|
---|
| 44 | uniform_distribution();
|
---|
[26612] | 45 | uniform_distribution(double _a,double _b);
|
---|
[26603] | 46 | ~uniform_distribution();
|
---|
[26598] | 47 |
|
---|
[26612] | 48 | double generator(rnd::linear_congruential_engine random_engine);
|
---|
[26598] | 49 |
|
---|
[26603] | 50 | };
|
---|
[26598] | 51 |
|
---|
[26603] | 52 | class normal_distribution
|
---|
| 53 | {
|
---|
[26598] | 54 |
|
---|
[26603] | 55 | private:
|
---|
| 56 | double mean;
|
---|
| 57 | double sdev;
|
---|
[26598] | 58 |
|
---|
[26603] | 59 | public:
|
---|
[26598] | 60 |
|
---|
[26603] | 61 | /*constructors, destructors: */
|
---|
| 62 | normal_distribution();
|
---|
| 63 | normal_distribution(double m,double s);
|
---|
| 64 | ~normal_distribution();
|
---|
[26598] | 65 |
|
---|
[26612] | 66 | double generator(rnd::linear_congruential_engine random_engine);
|
---|
[26598] | 67 |
|
---|
[26603] | 68 | };
|
---|
| 69 |
|
---|
[26616] | 70 | class lognormal_distribution
|
---|
| 71 | {
|
---|
[26612] | 72 |
|
---|
[26616] | 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 |
|
---|
[26619] | 122 | class student_t_distribution
|
---|
| 123 | {
|
---|
[26616] | 124 |
|
---|
[26619] | 125 | private:
|
---|
| 126 | unsigned int k;
|
---|
| 127 |
|
---|
| 128 | public:
|
---|
| 129 |
|
---|
| 130 | /*constructors, destructors: */
|
---|
| 131 | student_t_distribution();
|
---|
| 132 | student_t_distribution(unsigned int k);
|
---|
| 133 | ~student_t_distribution();
|
---|
| 134 |
|
---|
| 135 | double generator(rnd::linear_congruential_engine random_engine);
|
---|
| 136 |
|
---|
| 137 | };
|
---|
| 138 |
|
---|
| 139 |
|
---|
[26603] | 140 | }
|
---|
| 141 |
|
---|
[26612] | 142 | #endif //* _RANDOMGENERATOR_H_ */
|
---|