def ttost_paired(x1, x2, low, upp, transform=None, weights=None):
 if transform:
  if (transform is np.log):
   x1 = transform(x1)
   x2 = transform(x2)
  else:
   xx = transform(np.concatenate((x1, x2), 0))
   x1 = xx[:len(x1)]
   x2 = xx[len(x1):]
  low = transform(low)
  upp = transform(upp)
 dd = DescrStatsW((x1 - x2), weights=weights, ddof=0)
 (t1, pv1, df1) = dd.ttest_mean(low, alternative='larger')
 (t2, pv2, df2) = dd.ttest_mean(upp, alternative='smaller')
 return (np.maximum(pv1, pv2), (t1, pv1, df1), (t2, pv2, df2))

def ttost_paired ( x1 , x2 , low , upp , transform = None , weights = None ) : if transform : if ( transform is np . log ) : x1 = transform ( x1 ) x2 = transform ( x2 ) else : xx = transform ( np . concatenate ( ( x1 , x2 ) , 0 ) ) x1 = xx [ : len ( x1 ) ] x2 = xx [ len ( x1 ) : ] low = transform ( low ) upp = transform ( upp ) dd = DescrStatsW ( ( x1 - x2 ) , weights = weights , ddof = 0 ) ( t1 , pv1 , df1 ) = dd . ttest_mean ( low , alternative = 'larger' ) ( t2 , pv2 , df2 ) = dd . ttest_mean ( upp , alternative = 'smaller' ) return ( np . maximum ( pv1 , pv2 ) , ( t1 , pv1 , df1 ) , ( t2 , pv2 , df2 ) )
test of equivalence for two dependent .