! G08CCF Example Program Text ! Mark 23 Release. NAG Copyright 2011. MODULE g08ccfe_mod ! G08CCF Example Program Module: ! Parameters and User-defined Routines ! .. Use Statements .. USE nag_library, ONLY : nag_wp ! .. Implicit None Statement .. IMPLICIT NONE ! .. Parameters .. REAL (KIND=nag_wp), PARAMETER :: std = 0.5_nag_wp REAL (KIND=nag_wp), PARAMETER :: xmean = 0.75_nag_wp INTEGER, PARAMETER :: nin = 5, nout = 6 CONTAINS FUNCTION user_cdf(x) ! Cumulative distribution function for the user supplied distribution. ! In this example, the distribution is the normal distribution, with ! mean = 0.75 and standard deviation = 0.5 ! .. Use Statements .. USE nag_library, ONLY : s15abf ! .. Implicit None Statement .. IMPLICIT NONE ! .. Function Return Value .. REAL (KIND=nag_wp) :: user_cdf ! .. Scalar Arguments .. REAL (KIND=nag_wp), INTENT (IN) :: x ! .. Local Scalars .. REAL (KIND=nag_wp) :: z INTEGER :: ifail ! .. Executable Statements .. z = (x-xmean)/std ifail = -1 user_cdf = s15abf(z,ifail) RETURN END FUNCTION user_cdf END MODULE g08ccfe_mod PROGRAM g08ccfe ! G08CCF Example Main Program ! .. Use Statements .. USE nag_library, ONLY : g08ccf, nag_wp USE g08ccfe_mod, ONLY : nin, nout, user_cdf ! .. Implicit None Statement .. IMPLICIT NONE ! .. Local Scalars .. REAL (KIND=nag_wp) :: d, p, z INTEGER :: ifail, n, ntype ! .. Local Arrays .. REAL (KIND=nag_wp), ALLOCATABLE :: sx(:), x(:) ! .. Executable Statements .. WRITE (nout,*) 'G08CCF Example Program Results' WRITE (nout,*) ! Skip heading in data file READ (nin,*) ! Read in problem type and required statistic READ (nin,*) n, ntype ALLOCATE (x(n),sx(n)) ! Read in data READ (nin,*) x(1:n) ! Perform K-S test for user specified distribution ifail = 0 CALL g08ccf(n,x,user_cdf,ntype,d,z,p,sx,ifail) ! Display results WRITE (nout,*) 'Test against normal distribution with mean = 0.75' WRITE (nout,*) 'and standard deviation = 0.5.' WRITE (nout,*) WRITE (nout,99999) 'Test statistic D = ', d WRITE (nout,99999) 'Z statistic = ', z WRITE (nout,99999) 'Tail probability = ', p 99999 FORMAT (1X,A,F8.4) END PROGRAM g08ccfe