GNU Octave  3.8.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
gennor.f
Go to the documentation of this file.
1  REAL FUNCTION gennor(av,sd)
2 C**********************************************************************
3 C
4 C REAL FUNCTION GENNOR( AV, SD )
5 C
6 C GENerate random deviate from a NORmal distribution
7 C
8 C
9 C Function
10 C
11 C
12 C Generates a single random deviate from a normal distribution
13 C with mean, AV, and standard deviation, SD.
14 C
15 C
16 C Arguments
17 C
18 C
19 C AV --> Mean of the normal distribution.
20 C REAL AV
21 C
22 C SD --> Standard deviation of the normal distribution.
23 C REAL SD
24 C JJV (SD >= 0)
25 C
26 C GENNOR <-- Generated normal deviate.
27 C REAL GENNOR
28 C
29 C
30 C Method
31 C
32 C
33 C Renames SNORM from TOMS as slightly modified by BWB to use RANF
34 C instead of SUNIF.
35 C
36 C For details see:
37 C Ahrens, J.H. and Dieter, U.
38 C Extensions of Forsythe's Method for Random
39 C Sampling from the Normal Distribution.
40 C Math. Comput., 27,124 (Oct. 1973), 927 - 937.
41 C
42 C
43 C**********************************************************************
44 C .. Scalar Arguments ..
45  REAL av,sd
46 C ..
47 C .. External Functions ..
48  REAL snorm
49  EXTERNAL snorm
50 C ..
51 C .. Executable Statements ..
52 C JJV added check to ensure SD >= 0.0
53  IF (sd.GE.0.0) go to 10
54  WRITE (*,*) 'SD < 0.0 in GENNOR - ABORT'
55  WRITE (*,*) 'Value of SD: ',sd
56  CALL xstopx('SD < 0.0 in GENNOR - ABORT')
57 
58  10 gennor = sd*snorm() + av
59  RETURN
60 
61  END