|
Last change
on this file since 26574 was 26574, checked in by bulthuis, 4 years ago |
|
CHG: write pseudrandom number generators as a namespace
|
-
Property svn:executable
set to
*
|
|
File size:
1.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 | namespace rdn
|
|---|
| 9 | {
|
|---|
| 10 | class uniform_distribution
|
|---|
| 11 | {
|
|---|
| 12 |
|
|---|
| 13 | private:
|
|---|
| 14 |
|
|---|
| 15 | unsigned int a; //multiplier of the linear congruential generator
|
|---|
| 16 | unsigned int c; //increment of the linear congruential generator
|
|---|
| 17 | unsigned int m; // modulo of the linear congruential generator
|
|---|
| 18 | unsigned int _seed; // seed value
|
|---|
| 19 | double lbound; // lower bound of uniform distribution
|
|---|
| 20 | double ubound; // upper bound of uniform distribution
|
|---|
| 21 |
|
|---|
| 22 | public:
|
|---|
| 23 |
|
|---|
| 24 | /*constructors, destructors: */
|
|---|
| 25 | uniform_distribution();
|
|---|
| 26 | uniform_distribution(double a_1, double a_2);
|
|---|
| 27 | ~uniform_distribution();
|
|---|
| 28 |
|
|---|
| 29 | void seed( unsigned int s );
|
|---|
| 30 | unsigned int get_seed();
|
|---|
| 31 | double generator();
|
|---|
| 32 |
|
|---|
| 33 | };
|
|---|
| 34 |
|
|---|
| 35 | class normal_distribution
|
|---|
| 36 | {
|
|---|
| 37 |
|
|---|
| 38 | private:
|
|---|
| 39 | unsigned int _seed; // seed value
|
|---|
| 40 | double mean; // mean value
|
|---|
| 41 | double sdev; // standard deviation
|
|---|
| 42 |
|
|---|
| 43 | public:
|
|---|
| 44 |
|
|---|
| 45 | /*constructors, destructors: */
|
|---|
| 46 | normal_distribution();
|
|---|
| 47 | normal_distribution(double m,double s);
|
|---|
| 48 | ~normal_distribution();
|
|---|
| 49 |
|
|---|
| 50 | void seed( unsigned int s );
|
|---|
| 51 | double generator();
|
|---|
| 52 |
|
|---|
| 53 | };
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | }
|
|---|
| 57 | #endif //ifndef _RANDOMGENERATOR_H_
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.