* G08CGF Example Program Text * Mark 22 Revised. NAG Copyright 2006. * .. Parameters .. INTEGER NIN, NOUT, NMAX, NCLMAX, MSTATE, MSEED PARAMETER (NIN=5,NOUT=6,NMAX=100,NCLMAX=10,MSTATE=200, + MSEED=1) * .. Local Scalars .. DOUBLE PRECISION CHISQ, P, XMAX, XMIN INTEGER GENID, I, ICLASS, IFAIL, LSEED, LSTATE, N, + NCLASS, NDF, NPEST, SUBID CHARACTER DIST * .. Local Arrays .. DOUBLE PRECISION CB(NCLMAX), CHISQI(NCLMAX), EVAL(NCLMAX), PAR(2), + PROB(NCLMAX), X(NMAX) INTEGER IFREQ(NCLMAX), SEED(MSEED), STATE(MSTATE) * .. External Subroutines .. EXTERNAL G01AEF, G05KFF, G05SQF, G08CGF * .. Executable Statements .. WRITE (NOUT,*) 'G08CGF Example Program Results' * Skip heading in data file READ (NIN,*) READ (NIN,*) N, NCLASS, DIST READ (NIN,*) (PAR(I),I=1,2) NPEST = 0 * IFAIL = 0 * GENID and SUBID identify the base generator GENID = 1 SUBID = 1 * Initialize the seed SEED(1) = 32423 * Initialize the generator to a repeatable sequence LSTATE = MSTATE LSEED = MSEED CALL G05KFF(GENID,SUBID,SEED,LSEED,STATE,LSTATE,IFAIL) * Generate some U(A,B) variates CALL G05SQF(N,PAR(1),PAR(2),STATE,X,IFAIL) * ICLASS = 0 * * Determine suitable intervals IF (DIST.EQ.'U' .OR. DIST.EQ.'u') THEN ICLASS = 1 CB(1) = PAR(1) + (PAR(2)-PAR(1))/NCLASS DO 20 I = 2, NCLASS - 1 CB(I) = CB(I-1) + (PAR(2)-PAR(1))/NCLASS 20 CONTINUE END IF * CALL G01AEF(N,NCLASS,X,ICLASS,CB,IFREQ,XMIN,XMAX,IFAIL) * CALL G08CGF(NCLASS,IFREQ,CB,DIST,PAR,NPEST,PROB,CHISQ,P,NDF,EVAL, + CHISQI,IFAIL) * IF (IFAIL.NE.0) WRITE (NOUT,99999) '** IFAIL = ', IFAIL WRITE (NOUT,*) WRITE (NOUT,99998) 'Chi-squared test statistic = ', CHISQ WRITE (NOUT,99997) 'Degrees of freedom. = ', NDF WRITE (NOUT,99998) 'Significance level = ', P WRITE (NOUT,*) WRITE (NOUT,*) 'The contributions to the test statistic are :-' DO 40 I = 1, NCLASS WRITE (NOUT,99996) CHISQI(I) 40 CONTINUE * 99999 FORMAT (1X,A,I2) 99998 FORMAT (1X,A,F10.4) 99997 FORMAT (1X,A,I5) 99996 FORMAT (1X,F10.4) END