← 返回题库
中级

两总体均值差的置信区间配对样本

未完成
中级参考 代码结构已给出,请填写 ____ 处
def solve():
    import numpy as np
    import matplotlib.pyplot as plt
    from scipy import stats
    before = [____, ____, ____, ____, ____, ____, ____, ____, ____, ____]
    after  = [____, ____, ____, ____, ____, ____, ____, ____, ____, ____]
    diff = np.array(____) - np.array(____)
    n = len(____)
    mean_d = diff.mean()
    se_d = stats.sem(____)
    ci = stats.t.interval(____, df=n-____, loc=mean_d, scale=se_d)
    print(____)
    print(____)
    plt.plot(range(____), diff, '____', color='____')
    plt.axhline(____)
    plt.axhline(____, color='____', ls='____', alpha=____)
    plt.fill_between(range(____), ci[____], ci[____], alpha=____, color='____', label='____')
    plt.xlabel(____); plt.ylabel(____); plt.title(____); plt.legend()
    plt.tight_layout(); plt.show()

示例

输入
solve()
期望输出
均值差=3.00
95%CI: (1.63, 4.37)
Python 代码 🔒 登录后使用
🔒

登录后即可练习

注册免费账号,在浏览器中直接运行 Python 代码