Mercurial > octave
view libcruft/ranlib/gennch.f @ 2329:30c606bec7a8
[project @ 1996-07-19 01:29:05 by jwe]
Initial revision
author | jwe |
---|---|
date | Fri, 19 Jul 1996 01:29:55 +0000 |
parents | |
children | df7c57a6639d |
line wrap: on
line source
REAL FUNCTION gennch(df,xnonc) C********************************************************************** C C REAL FUNCTION GENNCH( DF, XNONC ) C Generate random value of Noncentral CHIsquare variable C C C Function C C C Generates random deviate from the distribution of a noncentral C chisquare with DF degrees of freedom and noncentrality parameter C XNONC. C C C Arguments C C C DF --> Degrees of freedom of the chisquare C (Must be > 1.0) C REAL DF C C XNONC --> Noncentrality parameter of the chisquare C (Must be >= 0.0) C REAL XNONC C C C Method C C C Uses fact that noncentral chisquare is the sum of a chisquare C deviate with DF-1 degrees of freedom plus the square of a normal C deviate with mean XNONC and standard deviation 1. C C********************************************************************** C .. Scalar Arguments .. REAL df,xnonc C .. C .. External Functions .. REAL genchi,gennor EXTERNAL genchi,gennor C .. C .. Intrinsic Functions .. INTRINSIC sqrt C .. C .. Executable Statements .. IF (.NOT. (df.LE.1.0.OR.xnonc.LT.0.0)) GO TO 10 WRITE (*,*) 'DF <= 1 or XNONC < 0 in GENNCH - ABORT' WRITE (*,*) 'Value of DF: ',df,' Value of XNONC',xnonc CALL XSTOPX ('DF <= 1 or XNONC < 0 in GENNCH - ABORT') 10 gennch = genchi(df-1.0) + gennor(sqrt(xnonc),1.0)**2 RETURN END