初级
绘制卡方分布
未完成 0%
初级参考
完整示例代码供参考,建议自己理解后重新输入
def solve():
import numpy as np
from scipy import stats
from sklearn.datasets import load_iris
iris = load_iris()
sepal_length = iris.data[:, 0]
n = len(sepal_length)
std = np.std(sepal_length, ddof=1)
# 方差的卡方置信区间
chi2_low = stats.chi2.ppf(0.025, df=n-1)
chi2_high = stats.chi2.ppf(0.975, df=n-1)
ci_low = (n-1)*std**2 / chi2_high
ci_high = (n-1)*std**2 / chi2_low
print(f'{ci_low:.4f},{ci_high:.4f}')
示例
输入
solve()
期望输出
0.5733,0.8337
👑
升级 VIP
解锁全部题目,畅通无阻地学习
- ✓ 解锁全部训练包所有题目
- ✓ 查看完整参考代码和提示
- ✓ 浏览器内直接运行 Python 代码
- ✓ 自动批改 + 进度追踪
30天
¥18
1年
¥99
2年
¥158
3年
¥199