scipy库中stats提供了双侧检验,如果需要单侧检验需要做一下处理
def ttest_onesided(s):
from spicy.stats import ttest_1samp
(t, p) = ttest_1samp(s, 0)
if t > 0:
onesided_p = 1 - p / 2
else:
onesided_p = p / 2
return onesided_p
```
scipy库中stats提供了双侧检验,如果需要单侧检验需要做一下处理
def ttest_onesided(s):
from spicy.stats import ttest_1samp
(t, p) = ttest_1samp(s, 0)
if t > 0:
onesided_p = 1 - p / 2
else:
onesided_p = p / 2
return onesided_p
```