您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

python中的学生t置信区间

python中的学生t置信区间

我猜你可以使用scipy.stats.t及其interval方法

In [1]: from scipy.stats import t
In [2]: t.interval(0.95, 10, loc=1, scale=2)  # 95% confidence interval
Out[2]: (-3.4562777039298762, 5.4562777039298762)
In [3]: t.interval(0.99, 10, loc=1, scale=2)  # 99% confidence interval
Out[3]: (-5.338545334351676, 7.338545334351676)

当然,如果您愿意,您可以发挥自己的作用。让我们看起来像在中Mathematica

from scipy.stats import t


def StudentTCI(loc, scale, df, alpha=0.95):
    return t.interval(alpha, df, loc, scale)

print StudentTCI(1, 2, 10)
print StudentTCI(1, 2, 10, 0.99)

结果:

(-3.4562777039298762, 5.4562777039298762)
(-5.338545334351676, 7.338545334351676)
python 2022/1/1 18:35:01 有226人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶