
            SUBROUTINE reg1(x,y,nb,nc,a,b,r,sd)

            INTEGER i
            REAL x(nb),y(nb)
            REAL a,b,r,sd

           sumx=0.0
           sumy=0.0

           DO i=1,nc
           sumx=sumx+x(i)
           sumy=sumy+y(i)
           ENDDO

           avex=sumx/real(nc)
           avey=sumy/real(nc)

           sqrx=0.0
           sk=0.0
           skk=0.0
           sqry=0.0
           sqryy=0.0
           DO i=1,nc
           sqrx=sqrx+(x(i)-avex)**2.
           sk=sk+(x(i)-avex)*(y(i)-avey)
           sqry=sqry+(y(i)-avey)**2.
           ENDDO


           b=sk/sqrx
           a=avey-b*avex
           r=sqrt(b**2*sqrx/sqry)
           sd=sqrt(sqry-b**2*sqrx)
           RETURN
           END
