GNU Octave  4.0.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
genchi.f
Go to the documentation of this file.
1  REAL FUNCTION genchi(df)
2 C**********************************************************************
3 C
4 C REAL FUNCTION GENCHI( DF )
5 C Generate random value of CHIsquare variable
6 C
7 C
8 C Function
9 C
10 C
11 C Generates random deviate from the distribution of a chisquare
12 C with DF degrees of freedom random variable.
13 C
14 C
15 C Arguments
16 C
17 C
18 C DF --> Degrees of freedom of the chisquare
19 C (Must be positive)
20 C REAL DF
21 C
22 C
23 C Method
24 C
25 C
26 C Uses relation between chisquare and gamma.
27 C
28 C**********************************************************************
29 C .. Scalar Arguments ..
30  REAL df
31 C ..
32 C .. External Functions ..
33 C REAL gengam
34 C EXTERNAL gengam
35  REAL sgamma
36  EXTERNAL sgamma
37 C ..
38 C .. 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 
44 C JJV changed this to call sgamma directly
45 C 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:1