GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
genf.f
Go to the documentation of this file.
1 REAL function genf(dfn,dfd)
2C**********************************************************************
3C
4C REAL FUNCTION GENF( DFN, DFD )
5C GENerate random deviate from the F distribution
6C
7C
8C Function
9C
10C
11C Generates a random deviate from the F (variance ratio)
12C distribution with DFN degrees of freedom in the numerator
13C and DFD degrees of freedom in the denominator.
14C
15C
16C Arguments
17C
18C
19C DFN --> Numerator degrees of freedom
20C (Must be positive)
21C REAL DFN
22C DFD --> Denominator degrees of freedom
23C (Must be positive)
24C REAL DFD
25C
26C
27C Method
28C
29C
30C Directly generates ratio of chisquare variates
31C
32C**********************************************************************
33C .. Scalar Arguments ..
34 REAL dfd,dfn
35C ..
36C .. Local Scalars ..
37 REAL xden,xnum
38C ..
39C JJV changed this code to call sgamma directly
40C .. External Functions ..
41C REAL genchi
42C EXTERNAL genchi
43 REAL sgamma
44 EXTERNAL sgamma
45C ..
46C .. Executable Statements ..
47 IF (.NOT. (dfn.LE.0.0.OR.dfd.LE.0.0)) GO TO 10
48 WRITE (*,*) 'Degrees of freedom nonpositive in GENF - abort!'
49 WRITE (*,*) 'DFN value: ',dfn,'DFD value: ',dfd
50 CALL xstopx ('Degrees of freedom nonpositive in GENF - abort!')
51
52 10 xnum = 2.0*sgamma(dfn/2.0)/dfn
53
54C GENF = ( GENCHI( DFN ) / DFN ) / ( GENCHI( DFD ) / DFD )
55 xden = 2.0*sgamma(dfd/2.0)/dfd
56C JJV changed constant so that it will not underflow at compile time
57C JJV while not slowing generator by using double precision or logs.
58C IF (.NOT. (xden.LE. (1.0E-38*xnum))) GO TO 20
59 IF (.NOT. (xden.LE. (1.0e-37*xnum))) GO TO 20
60 WRITE (*,*) ' GENF - generated numbers would cause overflow'
61 WRITE (*,*) ' Numerator ',xnum,' Denominator ',xden
62C JJV next 2 lines changed to maintain truncation of large deviates.
63C WRITE (*,*) ' GENF returning 1.0E38'
64C genf = 1.0E38
65 WRITE (*,*) ' GENF returning 1.0E37'
66 genf = 1.0e37
67 GO TO 30
68
69 20 genf = xnum/xden
70 30 RETURN
71
72 END
real function genf(dfn, dfd)
Definition genf.f:2
real function sgamma(a)
Definition sgamma.f:2