      SUBROUTINE TTEST(DATA1,N1,DATA2,N2,T,PROB)
      DIMENSION DATA1(N1),DATA2(N2)
      CALL AVEVAR(DATA1,N1,AVE1,VAR1)
      CALL AVEVAR(DATA2,N2,AVE2,VAR2)
      DF=N1+N2-2
      VAR=((N1-1)*VAR1+(N2-1)*VAR2)/DF
      T=(AVE1-AVE2)/SQRT(VAR*(1./N1+1./N2))
      PROB=BETAI(0.5*DF,0.5,DF/(DF+T**2))
      RETURN
      END
