假设实验之t检验

我们通常假设两个样本之间无显著差异作为原假设。

from scipy import stats
import numpy as np

data = [0.7922077922077922, 0.7922077922077922, 0.7748917748917749, 0.7229437229437229, 0.7878787878787878]
data = np.array(data)

mu = data.mean()
mu = mu - 0
t = mu / (np.std(data, ddof=1) / np.sqrt(len(data)))
p = (1 - stats.t.cdf(np.abs(t), len(data) - 1)) * 2
print("p值为:", p)

# test_res = stats.ttest_1samp(data, 0)

from scipy import stats
import numpy as np

score1 = [0.7922077922077922, 0.7922077922077922, 0.7748917748917749, 0.7229437229437229, 0.7878787878787878]
score2 = [0.7272727272727273, 0.6147186147186147, 0.70995670995671] # 两个样本长度不必相等

score1 = np.array(score1)
score2 = np.array(score2)

test_res = stats.ttest_ind(score1, score2)
print(test_res)

from scipy import stats
import numpy as np

score1 = [0.7922077922077922, 0.7922077922077922, 0.7748917748917749, 0.7229437229437229, 0.7878787878787878]
score2 = [0.7272727272727273, 0.6147186147186147, 0.70995670995671, 0.5887445887445888, 0.6536796536796536] # 两个样本长度必须相等

score1 = np.array(score1)
score2 = np.array(score2)

test_res = stats.ttest_rel(score1, score2)
print(test_res)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

清纯世纪

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值