home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 41 / IOPROG_41.ISO / soft / c++ / NUMCPP11.ZIP / deviate.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-04-10  |  8.9 KB  |  190 lines

  1. //===================================================================
  2. // deviate.h
  3. //
  4. // Version 1.1
  5. //
  6. // Written by:
  7. //   Brent Worden
  8. //   WordenWare
  9. //   email:  Brent@Worden.org
  10. //
  11. // Copyright (c) 1998-1999 WordenWare
  12. //
  13. // Created:  August 28, 1998
  14. // Revised:  April 10, 1999
  15. //===================================================================
  16.  
  17. #ifndef _DEVIATE_H_
  18. #define _DEVIATE_H_
  19.  
  20. #include "numerics.h"
  21.  
  22. NUM_BEGIN
  23.  
  24. // Function Prototypes
  25. NUMERICS_EXPORT double ran1(long *idum);
  26.  
  27. inline double RAND(long *seed)
  28. //--------------------------------------------------------------------
  29. // Function to let user specifiy the Uniform(0,1) generator of thier
  30. // choice.  RAND(seed) is then used by the other random variable
  31. // generators.
  32. //--------------------------------------------------------------------
  33. {
  34.        return ran1(seed);
  35. }
  36.  
  37. NUMERICS_EXPORT double ran0(long *idum);
  38. //--------------------------------------------------------------------
  39. // "Minimal" random number generator of Park and Miller.  Returns a
  40. // uniform random deviate between 0.0 and 1.0.  Set or reset idum to
  41. // any integer value to initialize the sequence; idum must not be
  42. // altered between calls for successive deviates in a sequence.
  43. //--------------------------------------------------------------------
  44.  
  45. NUMERICS_EXPORT double ran1(long *idum);
  46. //--------------------------------------------------------------------
  47. // "Minimal" random number generator of Park and Miller with
  48. // Bays-Durham shuffle and added safeguards.  Returns a uniform random
  49. // deviate between 0.0 and 1.0 (exclusive of the endpoint values).
  50. // Call with idum a negative integer to initialize; thereafter, do not
  51. // alter idum between successive deviates in a sequence.
  52. //--------------------------------------------------------------------
  53.  
  54. NUMERICS_EXPORT double ran2(long *idum);
  55. //--------------------------------------------------------------------
  56. // Long period (> 2 X 10^18) random number generator of L'Ecuyer with
  57. // Bays-Durham shuffle and added safeguards.  Returns a uniform random
  58. // deviate between 0.0 and 1.0 (exclusive of the endpoint values).
  59. // Call with idum a negative integer to initialize; thereafter, do not
  60. // alter idum between successive deviates in a sequence.
  61. //--------------------------------------------------------------------
  62.  
  63. NUMERICS_EXPORT double ran3(long *idum);
  64. //--------------------------------------------------------------------
  65. // Returns a uniform random deviate between 0.0 and 1.0.  Set idum to
  66. // any negative value to initialize or reinitialize the sequence.
  67. //--------------------------------------------------------------------
  68.  
  69. NUMERICS_EXPORT double berdev(double p, long *idum);
  70. //--------------------------------------------------------------------
  71. // Returns as a doubleing-point number an integer value that is a
  72. // random deviate drawn from a bernoulli distribution with probability
  73. // p, using RAND(idum) as a source of uniform deviates.
  74. //--------------------------------------------------------------------
  75.  
  76. NUMERICS_EXPORT double betadev(double a, double b, long *idum);
  77. //--------------------------------------------------------------------
  78. // Returns a beta distributed deviate with parameters a and b, using
  79. // RAND(idum) as the source of uniform deviates.
  80. //--------------------------------------------------------------------
  81.  
  82. NUMERICS_EXPORT double bnldev(int n, double p, long *idum);
  83. //--------------------------------------------------------------------
  84. // Returns as a doubleing-point number an integer value that is a
  85. // random deviate drawn from a binomial distribution of n trials each
  86. // of probability p, using RAND(idum) as a source of uniform deviates.
  87. //--------------------------------------------------------------------
  88.  
  89. NUMERICS_EXPORT double caudev(double m, double s, long *idum);
  90. //--------------------------------------------------------------------
  91. // Returns a cauchy distributed deviate with median m and scale s,
  92. // using RAND(idum) as the source of uniform deviates.
  93. //--------------------------------------------------------------------
  94.  
  95. NUMERICS_EXPORT double chidev(double v, long *idum);
  96. //--------------------------------------------------------------------
  97. // Returns a chi-squared distributed, random deviatate with v degrees
  98. // of freedom, using gamdev(v/2, 2, idum) as the source of gamma
  99. // deviates.
  100. //--------------------------------------------------------------------
  101.  
  102. NUMERICS_EXPORT double dexpdev(double m, double s, long *idum);
  103. //--------------------------------------------------------------------
  104. // Returns a double exponential distributed, random deviate of mean m
  105. // and scale parameter s, using RAND(idum) as the source of uniform
  106. // deviates.
  107. //--------------------------------------------------------------------
  108.  
  109. NUMERICS_EXPORT double expdev(double b, long *idum);
  110. //--------------------------------------------------------------------
  111. // Returns an exponentially distributed, random deviate of mean b,
  112. // using RAND(idum) as the source of uniform deviates.
  113. //--------------------------------------------------------------------
  114.  
  115. NUMERICS_EXPORT double fdev(double v1, double v2, long *idum);
  116. //--------------------------------------------------------------------
  117. // Returns a F distributed, random deviatate with v1 degrees of
  118. // freedom numerator and v2 degrees of freedom denominator using
  119. // RAND(idum) as the source of uniform deviates.
  120. //--------------------------------------------------------------------
  121.  
  122. NUMERICS_EXPORT double gamdev(double a, double b, long *idum);
  123. //--------------------------------------------------------------------
  124. // Returns a gamma distributed, random deviatate with parameters a and
  125. // b, using RAND(idum) as the source of uniform deviates.
  126. //--------------------------------------------------------------------
  127.  
  128. NUMERICS_EXPORT double gasdev(double m, double v, long *idum);
  129. //--------------------------------------------------------------------
  130. // Returns a normal distributed deviate with mean m and variance v,
  131. // using RAND(idum) as the source of uniform deviates.
  132. //--------------------------------------------------------------------
  133.  
  134. NUMERICS_EXPORT double logdev(double m, double b, long *idum);
  135. //-------------------------------------------------------------------
  136. // Returns a logistic dostrobited deviate with mean m and beta b,
  137. // using RAND(idum) as the source of uniform deviates.
  138. //-------------------------------------------------------------------
  139.  
  140. NUMERICS_EXPORT double nchidev(double df, double xnonc, long *idum);
  141. //-------------------------------------------------------------------
  142. // Returns a non-central chi-squared distributed deviate with df
  143. // degrees of freedom and non-centrallity parameter xnonc using
  144. // RAND(idum) as the source of uniform deviates.
  145. //-------------------------------------------------------------------
  146.  
  147. NUMERICS_EXPORT double nfdev(double dfn, double dfd, double xnonc, long *idum);
  148. //-------------------------------------------------------------------
  149. // Returns a non-central F distributed deviate with dfn degrees of
  150. // freedom numerator, dfd degrees of freedom denominator, and
  151. // non-centrallity parameter xnonc using RAND(idum) as the source of
  152. // uniform deviates.
  153. //-------------------------------------------------------------------
  154.  
  155. NUMERICS_EXPORT double poisdev(double m, long *idum);
  156. //--------------------------------------------------------------------
  157. // Returns an poisson distributed deviate with mean m, using
  158. // RAND(idum) as the source of uniform deviates.
  159. //--------------------------------------------------------------------
  160.  
  161. NUMERICS_EXPORT double tdev(double v, long *idum);
  162. //--------------------------------------------------------------------
  163. // Returns a Student's t distributed deviate with v degrees of
  164. // freedom, using RAND(idum) as the source of uniform deviates.
  165. //--------------------------------------------------------------------
  166.  
  167. NUMERICS_EXPORT double unifdev(double lo, double hi, long *idum);
  168. //--------------------------------------------------------------------
  169. // Returns an Uniform distributed deviate in the range of (lo, hi),
  170. // using RAND(idum) as the source of uniform(0,1) deviates.
  171. //--------------------------------------------------------------------
  172.  
  173. NUMERICS_EXPORT double weibdev(double a, double b, long *idum);
  174. //--------------------------------------------------------------------
  175. // Returns an weibull distributed deviate with parameters a and b,
  176. // using RAND(idum) as the source of uniform deviates.
  177. //--------------------------------------------------------------------
  178.  
  179. NUM_END
  180.  
  181. #endif
  182.  
  183. //===================================================================
  184. // Revision History
  185. //
  186. // Version 1.0 - 08/28/1998 - New.
  187. // Version 1.1 - 04/10/1999 - Added Numerics namespace.
  188. //===================================================================
  189.  
  190.