Program g08cbfe
! G08CBF Example Program Text
! Mark 30.3 Release. nAG Copyright 2024.
! .. Use Statements ..
Use nag_library, Only: g08cbf, nag_wp
! .. Implicit None Statement ..
Implicit None
! .. Parameters ..
Integer, Parameter :: nin = 5, nout = 6
! .. Local Scalars ..
Real (Kind=nag_wp) :: d, p, z
Integer :: ifail, n, npar, ntype
Character (2) :: dist
Character (1) :: estima
! .. Local Arrays ..
Real (Kind=nag_wp) :: par(2)
Real (Kind=nag_wp), Allocatable :: sx(:), x(:)
! .. Executable Statements ..
Write (nout,*) 'G08CBF Example Program Results'
Write (nout,*)
! Skip heading in data file
Read (nin,*)
! Read in problem size and the statistic to calculate
Read (nin,*) n, ntype
Allocate (x(n),sx(n))
! Read in data
Read (nin,*) x(1:n)
! Read in information on the distribution to test against
Read (nin,*) dist, estima
Select Case (dist)
Case ('P','p','E','e')
npar = 1
Case Default
npar = 2
End Select
! Read in the distribution parameters if required
! otherwise they are estimated from the data by G08CBF
! and PAR need not be set
If (estima=='S' .Or. estima=='s') Then
Read (nin,*) par(1:npar)
Else If (dist=='B' .Or. dist=='b' .Or. dist=='NB' .Or. dist=='nb') Then
! Read in M for the binomial distribution
Read (nin,*) par(1)
End If
! Perform K-S test
ifail = 0
Call g08cbf(n,x,dist,par,estima,ntype,d,z,p,sx,ifail)
! Display results
Write (nout,*) 'K-S Test'
Write (nout,*) 'Distribution: ', dist
Write (nout,99999) 'Parameters : ', par(1:npar)
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,2F8.4)
End Program g08cbfe