00001 00020 #ifndef _IRANDOM_H 00021 00022 #define _IRANDOM_H 00023 00030 class IRealRandom { 00034 public: 00035 virtual double rand(void)=0; 00036 virtual ~IRealRandom(void) {} 00037 }; 00038 00039 00048 class Random { 00049 public: 00055 Random(IRealRandom *random); 00059 virtual ~Random(void); 00060 00064 double rand(void) { 00065 return this->random->rand(); 00066 } 00067 00068 00077 int randint(unsigned low, unsigned high) { 00078 double random; 00079 00080 random = Random::rand(); 00081 return ( (int) (low + (high-low+1)*random) ); 00082 } 00083 00092 double randreal(double low, double high) { 00093 return (low + (high-low)*Random::rand()); 00094 } 00095 00096 00104 virtual double normal(double desv); 00105 00114 int getSample(int *sample, int *pmax); 00115 private: 00116 IRealRandom *random; 00117 }; 00118 00119 typedef Random* RandomPtr; 00120 00127 void initSample(int *sample, int max); 00128 00129 00130 #endif