3188
|
1 SUMMARY OF ROUTINES IN RANDLIB |
|
2 |
|
3 0. Base Level Routines to Set and Obtain Values of Seeds |
|
4 |
|
5 (These should be the only base level routines used by those who don't |
|
6 need multiple generators with blocks of numbers.) |
|
7 |
|
8 C********************************************************************** |
|
9 C |
|
10 C SUBROUTINE SETALL(ISEED1,ISEED2) |
|
11 C SET ALL random number generators |
|
12 C INTEGER ISEED1, ISEED2 |
|
13 C |
|
14 C********************************************************************** |
|
15 C********************************************************************** |
|
16 C |
|
17 C SUBROUTINE GETSD(ISEED1,ISEED2) |
|
18 C GET SeeD |
|
19 C INTEGER ISEED1, ISEED2 |
|
20 C |
|
21 C Returns the value of two integer seeds of the current generator |
|
22 C in ISEED1, ISEED2 |
|
23 C |
|
24 C********************************************************************** |
|
25 |
|
26 I. Higher Level Routines |
|
27 |
|
28 C********************************************************************** |
|
29 C |
|
30 C REAL FUNCTION GENBET( A, B ) |
|
31 C GeNerate BETa random deviate |
|
32 C REAL A,B |
|
33 C |
|
34 C Returns a single random deviate from the beta distribution with |
|
35 C parameters A and B. The density of the beta is |
|
36 C x^(a-1) * (1-x)^(b-1) / B(a,b) for 0 < x < 1 |
|
37 C |
|
38 C********************************************************************** |
|
39 C********************************************************************** |
|
40 C |
|
41 C REAL FUNCTION GENCHI( DF ) |
|
42 C Generate random value of CHIsquare variable |
|
43 C REAL DF |
|
44 C |
|
45 C Generates random deviate from the distribution of a chisquare |
|
46 C with DF degrees of freedom random variable. |
|
47 C |
|
48 C********************************************************************** |
|
49 C********************************************************************** |
|
50 C |
|
51 C REAL FUNCTION GENEXP( AV ) |
|
52 C GENerate EXPonential random deviate |
|
53 C REAL AV |
|
54 C |
|
55 C Generates a single random deviate from an exponential |
|
56 C distribution with mean AV. |
|
57 C |
|
58 C********************************************************************** |
|
59 C********************************************************************** |
|
60 C |
|
61 C REAL FUNCTION GENF( DFN, DFD ) |
|
62 C GENerate random deviate from the F distribution |
|
63 C REAL DFN, DFD |
|
64 C |
|
65 C Generates a random deviate from the F (variance ratio) |
|
66 C distribution with DFN degrees of freedom in the numerator |
|
67 C and DFD degrees of freedom in the denominator. |
|
68 C |
|
69 C********************************************************************** |
|
70 C********************************************************************** |
|
71 C |
|
72 C REAL FUNCTION GENGAM( A, R ) |
|
73 C GENerates random deviates from GAMma distribution |
|
74 C REAL A, R |
|
75 C |
|
76 C Generates random deviates from the gamma distribution whose |
|
77 C density is |
|
78 C (A**R)/Gamma(R) * X**(R-1) * Exp(-A*X) |
|
79 C |
|
80 C********************************************************************** |
|
81 C********************************************************************** |
|
82 C |
|
83 C SUBROUTINE GENMN(PARM,X,WORK) |
|
84 C GENerate Multivariate Normal random deviate |
|
85 C REAL PARM(*), X(*), WORK(*) |
|
86 C |
|
87 C PARM is set by SETGMN which must be called prior to GENMN. The |
|
88 C generated deviates are placed in X. WORK is a work array of the |
|
89 C same size as X. |
|
90 C |
|
91 C********************************************************************** |
|
92 C********************************************************************** |
|
93 C |
|
94 C SUBROUTINE GENMUL( N, P, NCAT, IX ) |
|
95 C GENerate MULtinomial random deviate |
|
96 C REAL P(*) |
|
97 C INTEGER N, NCAT, IX(*) |
|
98 C |
|
99 C Generates deviates from a Multinomial distribution with NCAT |
|
100 C categories. P specifies the probability of an event in each |
|
101 C category. The generated deviates are placed in IX. |
|
102 C |
|
103 C********************************************************************** |
|
104 C********************************************************************** |
|
105 C |
|
106 C REAL FUNCTION GENNCH( DF, XNONC ) |
|
107 C Generate random value of Noncentral CHIsquare variable |
|
108 C REAL DF, XNONC |
|
109 C |
|
110 C Generates random deviate from the distribution of a noncentral |
|
111 C chisquare with DF degrees of freedom and noncentrality parameter |
|
112 C XNONC. |
|
113 C |
|
114 C********************************************************************** |
|
115 C********************************************************************** |
|
116 C |
|
117 C REAL FUNCTION GENNF( DFN, DFD, XNONC ) |
|
118 C GENerate random deviate from the Noncentral F distribution |
|
119 C REAL DFN, DFD, XNONC |
|
120 C |
|
121 C Generates a random deviate from the noncentral F (variance ratio) |
|
122 C distribution with DFN degrees of freedom in the numerator, and DFD |
|
123 C degrees of freedom in the denominator, and noncentrality parameter |
|
124 C XNONC. |
|
125 C |
|
126 C********************************************************************** |
|
127 C********************************************************************** |
|
128 C |
|
129 C REAL FUNCTION GENNOR( AV, SD ) |
|
130 C GENerate random deviate from a NORmal distribution |
|
131 C REAL AV, SD |
|
132 C |
|
133 C Generates a single random deviate from a normal distribution |
|
134 C with mean, AV, and standard deviation, SD. |
|
135 C |
|
136 C********************************************************************** |
|
137 C********************************************************************** |
|
138 C |
|
139 C SUBROUTINE GENPRM( IARRAY, LARRAY ) |
|
140 C GENerate random PeRMutation of iarray |
|
141 C INTEGER IARRAY(LARRAY), LARRAY |
|
142 C |
|
143 C********************************************************************** |
|
144 C********************************************************************** |
|
145 C |
|
146 C REAL FUNCTION GENUNF( LOW, HIGH ) |
|
147 C GeNerate Uniform Real between LOW and HIGH |
|
148 C REAL LOW, HIGH |
|
149 C |
|
150 C********************************************************************** |
|
151 C********************************************************************** |
|
152 C |
|
153 C INTEGER FUNCTION IGNBIN( N, P ) |
|
154 C GENerate BINomial random deviate |
|
155 C INTEGER N |
|
156 C REAL P |
|
157 C |
|
158 C Returns a single random deviate from a binomial |
|
159 C distribution whose number of trials is N and whose |
|
160 C probability of an event in each trial is P. |
|
161 C |
|
162 C********************************************************************** |
|
163 C********************************************************************** |
|
164 C |
|
165 C INTEGER FUNCTION IGNNBN( N, P ) |
|
166 C GENerate Negative BiNomial random deviate |
|
167 C INTEGER N |
|
168 C REAL P |
|
169 C |
|
170 C Returns a single random deviate from a negative binomial |
|
171 C distribution with number of events N and whose |
|
172 C probability of an event in each trial is P. |
|
173 C |
|
174 C********************************************************************** |
|
175 C********************************************************************** |
|
176 C |
|
177 C INTEGER FUNCTION IGNPOI( AV ) |
|
178 C GENerate POIsson random deviate |
|
179 C REAL AV |
|
180 C |
|
181 C Generates a single random deviate from a Poisson |
|
182 C distribution with mean AV. |
|
183 C |
|
184 C********************************************************************** |
|
185 C********************************************************************** |
|
186 C |
|
187 C INTEGER FUNCTION IGNUIN( LOW, HIGH ) |
|
188 C GeNerate Uniform INteger |
|
189 C INTEGER LOW, HIGH |
|
190 C |
|
191 C Generates an integer uniformly distributed between LOW and HIGH. |
|
192 C |
|
193 C********************************************************************** |
|
194 C********************************************************************** |
|
195 C |
|
196 C SUBROUTINE PHRTSD( PHRASE, SEED1, SEED2 ) |
|
197 C PHRase To SeeDs |
|
198 C CHARACTER*(*) PHRASE |
|
199 C INTEGER SEED1, SEED2 |
|
200 C |
|
201 C Uses a phrase (character string) to generate two seeds for the RGN |
|
202 C random number generator. |
|
203 C |
|
204 C********************************************************************** |
|
205 C********************************************************************** |
|
206 C |
|
207 C REAL FUNCTION RANF() |
|
208 C RANDom number generator as a Function |
|
209 C |
|
210 C Returns a random floating point number from a uniform distribution |
|
211 C over 0 - 1 (endpoints of this interval are not returned) using the |
|
212 C current generator |
|
213 C |
|
214 C********************************************************************** |
|
215 C********************************************************************** |
|
216 C |
|
217 C SUBROUTINE SETGMN( MEANV, COVM, LDCOVM, P, PARM) |
|
218 C SET Generate Multivariate Normal random deviate |
|
219 C INTEGER LDCOVM, P |
|
220 C REAL MEANV(P), COVM(LDCOVM,P), PARM(P*(P+3)/2 + 1) |
|
221 C |
|
222 C P is the length of normal vectors to be generated, MEANV |
|
223 C is the vector of their means and COVM(1:P,1:P) is their variance |
|
224 C covariance matrix. LDCOVM is the leading actual dimension of |
|
225 C COVM, which this routine needs to know although only the |
|
226 C (1:P,1:P) slice of COVM is used. |
|
227 C Places information necessary to generate the deviates in PARM. |
|
228 C |
|
229 C********************************************************************** |
|
230 |
|
231 II. Uniform Generator and Associated Routines |
|
232 |
|
233 |
|
234 A. SETTING THE SEED OF ALL GENERATORS |
|
235 |
|
236 C********************************************************************** |
|
237 C |
|
238 C SUBROUTINE SETALL(ISEED1,ISEED2) |
|
239 C SET ALL random number generators |
|
240 C INTEGER ISEED1, ISEED2 |
|
241 C |
|
242 C********************************************************************** |
|
243 |
|
244 B. OBTAINING RANDOM NUMBERS |
|
245 |
|
246 C********************************************************************** |
|
247 C |
|
248 C INTEGER FUNCTION IGNLGI() |
|
249 C GeNerate LarGe Integer |
|
250 C |
|
251 C Returns a random integer following a uniform distribution over |
|
252 C (1, 2147483562) using the current generator. |
|
253 C |
|
254 C********************************************************************** |
|
255 |
|
256 C********************************************************************** |
|
257 C |
|
258 C REAL FUNCTION RANF() |
|
259 C RANDom number generator as a Function |
|
260 C |
|
261 C Returns a random floating point number from a uniform distribution |
|
262 C over 0 - 1 (endpoints of this interval are not returned) using the |
|
263 C current generator |
|
264 C |
|
265 C********************************************************************** |
|
266 |
|
267 C. SETTING AND OBTAINING THE NUMBER OF THE CURRENT GENERATOR |
|
268 |
|
269 C********************************************************************** |
|
270 C |
|
271 C SUBROUTINE SETCGN( G ) |
|
272 C Set GeNerator |
|
273 C INTEGER G |
|
274 C |
|
275 C Sets the current generator to G. All references to a generator |
|
276 C are to the current generator. |
|
277 C |
|
278 C********************************************************************** |
|
279 |
|
280 C********************************************************************** |
|
281 C |
|
282 C SUBROUTINE GETCGN(G) |
|
283 C GET Current GeNerator |
|
284 C INTEGER G |
|
285 C |
|
286 C Returns in G the number of the current random number generator |
|
287 C |
|
288 C********************************************************************** |
|
289 |
|
290 D. OBTAINING OR CHANGING SEEDS IN CURRENT GENERATOR |
|
291 |
|
292 C********************************************************************** |
|
293 C |
|
294 C SUBROUTINE ADVNST(K) |
|
295 C ADV-a-N-ce ST-ate |
|
296 C INTEGER K |
|
297 C |
|
298 C Advances the state of the current generator by 2^K values and |
|
299 C resets the initial seed to that value. |
|
300 C |
|
301 C********************************************************************** |
|
302 |
|
303 C********************************************************************** |
|
304 C |
|
305 C SUBROUTINE GETSD(ISEED1,ISEED2) |
|
306 C GET SeeD |
|
307 C INTEGER ISEED1, ISEED2 |
|
308 C |
|
309 C Returns the value of two integer seeds of the current generator |
|
310 C in ISEED1, ISEED2 |
|
311 C |
|
312 C********************************************************************** |
|
313 |
|
314 C********************************************************************** |
|
315 C |
|
316 C SUBROUTINE INITGN(ISDTYP) |
|
317 C INIT-ialize current G-e-N-erator |
|
318 C |
|
319 C INTEGER ISDTYP The state to which the generator is to be set |
|
320 C ISDTYP = -1 => sets the seeds to their initial value |
|
321 C ISDTYP = 0 => sets the seeds to the first value of |
|
322 C the current block |
|
323 C ISDTYP = 1 => sets the seeds to the first value of |
|
324 C the next block |
|
325 C |
|
326 C********************************************************************** |
|
327 |
|
328 C********************************************************************** |
|
329 C |
|
330 C SUBROUTINE SETSD(ISEED1,ISEED2) |
|
331 C SET S-ee-D of current generator |
|
332 C |
|
333 C Resets the initial seed of the current generator to ISEED1 and |
|
334 C ISEED2. The seeds of the other generators remain unchanged. |
|
335 C |
|
336 C********************************************************************** |
|
337 |
|
338 E. MISCELLANY |
|
339 |
|
340 C********************************************************************** |
|
341 C |
|
342 C INTEGER FUNCTION MLTMOD(A,S,M) |
|
343 C Returns (A*S) MOD M |
|
344 C INTEGER A, S, M |
|
345 C |
|
346 C********************************************************************** |
|
347 |
|
348 C********************************************************************** |
|
349 C |
|
350 C SUBROUTINE SETANT(QVALUE) |
|
351 C SET ANTithetic |
|
352 C LOGICAL QVALUE |
|
353 C |
|
354 C Sets whether the current generator produces antithetic values. If |
|
355 C X is the value normally returned from a uniform [0,1] random |
|
356 C number generator then 1 - X is the antithetic value. If X is the |
|
357 C value normally returned from a uniform [0,N] random number |
|
358 C generator then N - 1 - X is the antithetic value. |
|
359 C |
|
360 C All generators are initialized to NOT generate antithetic values. |
|
361 C |
|
362 C********************************************************************** |
|
363 |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |