      program ex091
      implicit real*8(a-h,o-z)
      integer*4 iseed
c     dimension hist(50)
c
      iseed = 123456789
      n = 100000
c     dx = 1.0d0/50
c
c     do j = 1,50
c        hist(j) = 0.0d0
c     end do
c
      ave=0.0d0
      sgm=0.0d0
      do i = 1,n
         x = rnd(iseed)
c        j = int(x/dx)+1
c        hist(j) = hist(j) + 1.0d0
         ave = ave + x
         sgm = sgm + x**2
      end do
      ave = ave/n
      sgm = sgm/n
      sgm = sqrt(sgm - ave**2)
      write(*,*) 'Average (Heikin)   =',ave
      write(*,*) 'Standard Deviation =',sgm

c
c     do j = 1,50
c        write(*,100) dx*(j+0.5d0),hist(j)/n/dx
c     end do
c
c100  format(2(1x,f10.4))
      end
c **********************************************************************
      function rnd(iseed)
c **********************************************************************
      implicit real*8(a-h,o-z)
c...32 bit (=4byte) machine
      integer*4 iseed,il,ic,ih
      il = 843314861
      ic = 453816693
      ih = 2**30
      xmax = 2.0d0**31
c
      iseed = iseed*il + ic
      if(iseed.lt.0) iseed = (iseed + ih) + ih
      rnd = iseed/xmax
c
      end
