    PROGRAM nag_basic_stats_ex01

      ! Example Program Text for nag_basic_stats
      ! NAG fl90, Release 4. NAG Copyright 2000.

      ! .. Use Statements ..
      USE nag_examples_io, ONLY : nag_std_out, nag_std_in
      USE nag_basic_stats, ONLY : nag_summary_stats_1v
      ! .. Implicit None Statement ..
      IMPLICIT NONE
      ! .. Intrinsic Functions ..
      INTRINSIC KIND
      ! .. Parameters ..
      INTEGER, PARAMETER :: wp = KIND(1.0D0)
      CHARACTER (*), PARAMETER :: fmt = '(/1x,a,/,(9f8.1))'
      ! .. Local Scalars ..
      INTEGER :: n
      REAL (wp) :: coeff_var, kurtosis, max_value, mean, min_value, range, &
       skewness, std_dev, std_err_mean, sum_wt, variance
      ! .. Local Arrays ..
      REAL (wp), ALLOCATABLE :: wt(:), x(:)
      ! .. Executable Statements ..
      WRITE (nag_std_out,*) 'Example Program Results for nag_basic_stats_ex01'

      READ (nag_std_in,*)          ! Skip heading in data file
      READ (nag_std_in,*) n

      ALLOCATE (x(n),wt(n))        ! Allocate storage

      READ (nag_std_in,*) x
      READ (nag_std_in,*) wt
      WRITE (nag_std_out,fmt) 'Data values', x
      WRITE (nag_std_out,fmt) 'Weights', wt

      CALL nag_summary_stats_1v(x,wt=wt,mean=mean,variance=variance, &
       std_dev=std_dev,std_err_mean=std_err_mean,skewness=skewness, &
       kurtosis=kurtosis,coeff_var=coeff_var,max_value=max_value, &
       min_value=min_value,range=range,sum_wt=sum_wt)

      WRITE (nag_std_out,*)
      WRITE (nag_std_out,'(1x,a,1pe11.4)') 'Mean                     = ', &
       mean, 'Variance                 = ', variance, &
       'Standard deviation       = ', std_dev, 'Standard error for mean  = ', &
       std_err_mean, 'Skewness                 = ', skewness, &
       'Kurtosis                 = ', kurtosis, 'Coefficient of variation = ', &
       coeff_var, 'Maximum value            = ', max_value, &
       'Minimum value            = ', min_value, 'Range                    = ' &
       , range, 'Sum of weights           = ', sum_wt

      DEALLOCATE (x,wt)            ! Deallocate storage

    END PROGRAM nag_basic_stats_ex01
