NAG Library Manual, Mark 30
Interfaces:  FL   CL   CPP   AD 

NAG FL Interface Introduction
Example description
    Program g07ddfe

!     G07DDF Example Program Text

!     Mark 30.0 Release. NAG Copyright 2024.

!     .. Use Statements ..
      Use nag_library, Only: g07ddf, nag_wp
!     .. Implicit None Statement ..
      Implicit None
!     .. Parameters ..
      Integer, Parameter               :: nin = 5, nout = 6
!     .. Local Scalars ..
      Real (Kind=nag_wp)               :: alpha, propn, tmean, tvar, wmean,    &
                                          wvar
      Integer                          :: ifail, k, n
!     .. Local Arrays ..
      Real (Kind=nag_wp), Allocatable  :: sx(:), x(:)
!     .. Intrinsic Procedures ..
      Intrinsic                        :: real
!     .. Executable Statements ..
      Write (nout,*) 'G07DDF Example Program Results'
      Write (nout,*)

!     Skip heading in data file
      Read (nin,*)

!     Read in the problem size
      Read (nin,*) n, alpha

      Allocate (x(n),sx(n))

!     Read in data
      Read (nin,*) x(1:n)

!     Trim data
      ifail = 0
      Call g07ddf(n,x,alpha,tmean,wmean,tvar,wvar,k,sx,ifail)

!     Calculate proportion of data cut
      propn = real(k,kind=nag_wp)/real(n,kind=nag_wp)
      propn = 100.0E0_nag_wp - 200.0E0_nag_wp*propn

!     Display results
      Write (nout,99999) 'Statistics from middle ', propn, '% of data'
      Write (nout,*)
      Write (nout,99998) '               Trimmed-mean = ', tmean
      Write (nout,99998) '   Variance of Trimmed-mean = ', tvar
      Write (nout,*)
      Write (nout,99998) '            Winsorized-mean = ', wmean
      Write (nout,99998) 'Variance of Winsorized-mean = ', wvar

99999 Format (1X,A,F6.2,A)
99998 Format (1X,A,F11.4)
    End Program g07ddfe