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