REAL*8 FUNCTION CHI(S2,ANU) C This routine generates a random variable z, where C S2*z~chi-square(nu). C Inputs: C S2 Numerator parameter s2 C ANU Degrees of freedom parameter nu C Output: C CHI Random variable z IMPLICIT REAL*8 (A-H,O-Z) CALL DRNCHI(1,ANU,CHISQ) CHI=CHISQ/S2 RETURN END REAL*8 FUNCTION CHIK(S2,ANU,X) C This routine evaluates the log density kernel of a random variable C z for which S2*z~chi-square(ANU), at the point x. C The log density kernel is C ((nu-2)/2)*log(x) - s2*x/2 C Inputs: C S2 Numerator parameter s2 C ANU Degrees of freedom parameter nu C X Point of evaluation x C Output C CHIK Value of log density kernel IMPLICIT REAL*8 (A-H,O-Z) CHIK=0.5D0*((ANU-2.0D0)*DLOG(X)-S2*X) RETURN END REAL*8 FUNCTION CHIN(S2,ANU) C*********************************************************************** C In the calling routine a call to INIT must be made prior to calling * C this routine for the first time. * C*********************************************************************** C This routine evaluates the log normalizing constant for the log C density kernel of a random variable computed in CHIK. This C normalizing constant, when multiplied by the kernel in CHIK, C yields the p.d.f. of a random variable z for which S2*z~chi- C square(ANU) C Inputs: C S2 Numerator parameter s2 C ANU Degrees of freedom parameter nu C Output C CHIN Value of log normalizing constant IMPLICIT REAL*8 (A-H,O-Z) COMMON/CONST/DLOG2,DLGPI,HLG2PI,PI,PII AA=0.5D0*ANU BB=DLNGAM(AA) CHIN=-AA*DLOG2-DLNGAM(AA)+AA*DLOG(S2) RETURN END