home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / db02_src.zip / rand.h < prev    next >
C/C++ Source or Header  |  1993-11-05  |  1KB  |  46 lines

  1. //
  2. // Source     : rand.h
  3. // Author     : Darren Platt
  4. // Version    : 1.1
  5. // Date Begun : 10.5.91
  6. // Last Rev   : 92/05/18
  7. // Id String  : @(#)rand.h    1.1
  8. // 
  9. // Modification log
  10. //-----------------
  11. // 0.0  tjp        Tom was here.
  12. // 1.1    daz        Added to SCCS
  13.  
  14. #ifndef _RANDOM_
  15. #define _RANDOM_
  16. void seed_random(unsigned long);
  17. unsigned long my_rand(void);
  18.  
  19. const unsigned long max_ulong = 0xffffffff;
  20.  
  21. // The random number generator class contains a number of methods for
  22. // generating random numbers with different distributions. It also has
  23. // its own seeds making it good for use in simulations.
  24. class randcl {
  25.         unsigned long     *rand_table;
  26.         unsigned long     lahmer_seed;
  27.         int                phase;
  28.         double            sqratio,q;
  29.         long             taus_seed;
  30.         inline    void    grab(void);
  31.         inline    void    ungrab(void);
  32.         inline    double    quick_unit(void);
  33.     public:
  34.                     randcl(unsigned long);    // seed
  35.                     randcl(void);
  36.                     ~randcl();
  37.     unsigned long    ulong(void);
  38.         void        seed(unsigned long);
  39.         double        unit(void);
  40.         double        neg_exp(double);        // mean
  41.         double        uniform(double,double);    // lower,upper
  42.         long        uniformInt(long,long);    // lower,upper
  43.         double        normal(double,double);    // mean,sd
  44. };
  45. #endif
  46.