      SUBROUTINE TPTEST(DATA1,DATA2,N,T,PROB)
      DIMENSION DATA1(N),DATA2(N)
      CALL AVEVAR(DATA1,N,AVE1,VAR1)
      CALL AVEVAR(DATA2,N,AVE2,VAR2)
      COV=0.
      DO 11 J=1,N
        COV=COV+(DATA1(J)-AVE1)*(DATA2(J)-AVE2)
11    CONTINUE
      DF=N-1
      COV=COV/DF
      SD=SQRT((VAR1+VAR2-2.*COV)/N)
      T=(AVE1-AVE2)/SD
      PROB=BETAI(0.5*DF,0.5,DF/(DF+T**2))
      RETURN
      END
