      subroutine steb1(n,x,w,xm,xe) ! bernd berg feb 14 1990.
c  input:   array x (gaussian) data and weight factors.
c  output:  mean value xm, and its error bar xe.
c           weight factors normalized to one.
      include '../../libs/fortran/implicit.sta'
      include '../../libs/fortran/constants.par'
      dimension x(n),w(n)
c
c normalization of weight factors:
      wnorm=zero
      do i=1,n
        wnorm=wnorm+w(i)
      end do
      do i=1,n
        w(i)=w(i)/wnorm
      end do
c weighted mean value:
      xm=zero
      do i=1,n
        xm=xm+w(i)*x(i)
      end do
c unbiased estimator for xe**2 (variance of the mean):
      xv=zero
      do i=1,n
        xv=xv+w(i)*(x(i)-xm)**2
      end do       
      xe=sqrt(xv/((n-1)*one))
c
      return
      end
