GNU Octave 10.1.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 
Loading...
Searching...
No Matches
genchi.f
Go to the documentation of this file.
1 REAL function genchi(df)
2C**********************************************************************
3C
4C REAL FUNCTION GENCHI( DF )
5C Generate random value of CHIsquare variable
6C
7C
8C Function
9C
10C
11C Generates random deviate from the distribution of a chisquare
12C with DF degrees of freedom random variable.
13C
14C
15C Arguments
16C
17C
18C DF --> Degrees of freedom of the chisquare
19C (Must be positive)
20C REAL DF
21C
22C
23C Method
24C
25C
26C Uses relation between chisquare and gamma.
27C
28C**********************************************************************
29C .. Scalar Arguments ..
30 REAL df
31C ..
32C .. External Functions ..
33C REAL gengam
34C EXTERNAL gengam
35 REAL sgamma
36 EXTERNAL sgamma
37C ..
38C .. Executable Statements ..
39 IF (.NOT. (df.LE.0.0)) GO TO 10
40 WRITE (*,*) 'DF <= 0 in GENCHI - ABORT'
41 WRITE (*,*) 'Value of DF: ',df
42 CALL xstopx ('DF <= 0 in GENCHI - ABORT')
43
44C JJV changed this to call sgamma directly
45C 10 genchi = 2.0*gengam(1.0,df/2.0)
46 10 genchi = 2.0*sgamma(df/2.0)
47 RETURN
48
49 END
real function genchi(df)
Definition genchi.f:2
real function sgamma(a)
Definition sgamma.f:2