C  Simple tests of mpf_random

      program testrand

      integer, parameter :: V = 8192
      INCLUDE 'mpfrand.h'

      integer IR(V), k, n, seed, time
      real, array(V) :: U, U0, Ux, S, SS, CS, S2
      real mu, sigma, mucorr, sgcorr

      print *, "Specify n <= 0 to quit."
      do while (.TRUE.)
         print '(" n, seed > "$)'
         read *, n, seed
         if ( n <= 0 ) go to 99       ! Exit
         call mpTimerStart()
         IR = seed + [1:V]            ! Seed vector
         call mpf_srandom(IR)
         call mpf_random(IR)
         U0 = IR/Two31      ! 0-th random number
         Ux = U0            ! Previous random number
         S = Ux             ! Sum of random numbers
         SS = Ux*Ux         ! Sum of squares
         CS = 0.0           ! Correlation sum
         do, k = 1, n-1     ! Loop through n - 1 random numbers
            call mpf_random(IR)
            U = IR/Two31
            S = S + U
            SS = SS + U*U
            CS = CS + Ux*U
            Ux = U
         end do
         CS = CS + Ux*U0     ! Finish correlation sum
C      Calculate individual statistics
         S2 = S*S
         CS = (n*CS - S2)/(n*SS - S2)   ! Correlation coefficient
         S  = S/n                       ! Mean
         mu = sum(S)/V                  ! Overall mean
         sigma = sum(SS)/(n*V) - mu*mu  ! Overall variance
         sigma = sqrt(sigma)            ! Overall standard deviation
         SS = sqrt(SS/n - S*S)          ! Standard deviation
         mucorr = sum(CS)/V             ! Mean corr. coeff.
         sgcorr = sum(CS*CS)/V - mucorr*mucorr ! sigma(CS)
         time = mpTimerElapsed()
C      Table:      SSSSSSSSS  -d.ddddd  -d.ddddd  -d.ddddd  -d.ddddd
         print '(" Statistic     Min       Mean      Max      Total")'
         print 22, "mean ", minval(S),     mu,     maxval(S),  mu
         print 22, "sigma", minval(SS), sum(SS)/V, maxval(SS), sigma
         print 22, "corr ", minval(CS),   mucorr,  maxval(CS)
 22      FORMAT (1X, A9, 4(2X, F8.5))
         print 23, sgcorr
 23      FORMAT (1X, "sigma(corr) = ", F8.5)
         print *, "Time: ", time/1000.0
      end do
 99   continue            ! For exit
      end program testrand
