GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
gennf.f
Go to the documentation of this file.
1 REAL function gennf(dfn,dfd,xnonc)
2
3C**********************************************************************
4C
5C REAL FUNCTION GENNF( DFN, DFD, XNONC )
6C GENerate random deviate from the Noncentral F distribution
7C
8C
9C Function
10C
11C
12C Generates a random deviate from the noncentral F (variance ratio)
13C distribution with DFN degrees of freedom in the numerator, and DFD
14C degrees of freedom in the denominator, and noncentrality parameter
15C XNONC.
16C
17C
18C Arguments
19C
20C
21C DFN --> Numerator degrees of freedom
22C (Must be >= 1.0)
23C REAL DFN
24C DFD --> Denominator degrees of freedom
25C (Must be positive)
26C REAL DFD
27C
28C XNONC --> Noncentrality parameter
29C (Must be nonnegative)
30C REAL XNONC
31C
32C
33C Method
34C
35C
36C Directly generates ratio of noncentral numerator chisquare variate
37C to central denominator chisquare variate.
38C
39C**********************************************************************
40C .. Scalar Arguments ..
41 REAL dfd,dfn,xnonc
42C ..
43C .. Local Scalars ..
44 REAL xden,xnum
45 LOGICAL qcond
46C ..
47C .. External Functions ..
48C JJV changed the code to call SGAMMA and SNORM directly
49C REAL genchi,gennch
50C EXTERNAL genchi,gennch
51 REAL sgamma,snorm
52 EXTERNAL sgamma,snorm
53C ..
54C .. Executable Statements ..
55C JJV changed the argument checker to allow DFN = 1.0
56C JJV in the same way as GENNCH was changed.
57 qcond = dfn .LT. 1.0 .OR. dfd .LE. 0.0 .OR. xnonc .LT. 0.0
58 IF (.NOT. (qcond)) GO TO 10
59 WRITE (*,*) 'In GENNF - Either (1) Numerator DF < 1.0 or'
60 WRITE (*,*) '(2) Denominator DF <= 0.0 or '
61 WRITE (*,*) '(3) Noncentrality parameter < 0.0'
62 WRITE (*,*) 'DFN value: ',dfn,'DFD value: ',dfd,'XNONC value: ',
63 + xnonc
64
65 CALL xstopx
66 + ('Degrees of freedom or noncent param out of range in GENNF')
67
68C GENNF = ( GENNCH( DFN, XNONC ) / DFN ) / ( GENCHI( DFD ) / DFD )
69C JJV changed this to call SGAMMA and SNORM directly
70C xnum = gennch(dfn,xnonc)/dfn
71 10 IF (dfn.GE.1.000001) GO TO 20
72C JJV case dfn = 1.0 - here I am treating dfn as exactly 1.0
73 xnum = (snorm() + sqrt(xnonc))**2
74 GO TO 30
75
76C JJV case dfn > 1.0
77 20 xnum = (2.0*sgamma((dfn-1.0)/2.0) + (snorm()+sqrt(xnonc))**2)/dfn
78
79C xden = genchi(dfd)/dfd
80 30 xden = 2.0*sgamma(dfd/2.0)/dfd
81
82C JJV changed constant so that it will not underflow at compile time
83C JJV while not slowing generator by using double precision or logs.
84C IF (.NOT. (xden.LE. (1.0E-38*xnum))) GO TO 40
85 IF (.NOT. (xden.LE. (1.0e-37*xnum))) GO TO 40
86 WRITE (*,*) ' GENNF - generated numbers would cause overflow'
87 WRITE (*,*) ' Numerator ',xnum,' Denominator ',xden
88C JJV next 2 lines changed to maintain truncation of large deviates.
89C WRITE (*,*) ' GENNF returning 1.0E38'
90C gennf = 1.0E38
91 WRITE (*,*) ' GENNF returning 1.0E37'
92 gennf = 1.0e37
93 GO TO 50
94
95 40 gennf = xnum/xden
96 50 RETURN
97
98 END
real function gennf(dfn, dfd, xnonc)
Definition gennf.f:2
real function sgamma(a)
Definition sgamma.f:2
real function snorm()
Definition snorm.f:2