      function hist_aver(n1,n2,h) ! bernd berg nov 24 2004.
c calculation of the average (mean) from a histogram h(n1:n2).
      include '../../libs/fortran/implicit.sta'
      dimension h(n1:n2)
      hist_aver=0
      hsum=0
      do i=n1,n2
        hist_aver=hist_aver+i*h(i)
        hsum=hsum+h(i)
      end do
      hist_aver=hist_aver/hsum
      return
      end
