给出下面代码注释from scipy.stats import norm from numpy import * n=36 mu = 70 sigma = 15 xbar = 66.5 alpha = 0.05 rig = 1-alpha/2 left = alpha/2 z = (xbar-mu)/(sigma/sqrt(n))q1 = norm.ppf(left,,1)q2 = norm.ppf(rig,,1) if q1 <= z <= q2:print('Accept xbar = mu')else:
时间: 2023-08-14 14:04:39 浏览: 243
Numpy学习指南代码
# 导入norm函数用于正态分布的概率密度函数和累计分布函数的计算
# 导入numpy库中的sqrt函数用于计算样本数的平方根
from scipy.stats import norm
from numpy import *
# 样本量为36,总体均值为70,总体标准差为15,样本均值为66.5
n = 36
mu = 70
sigma = 15
xbar = 66.5
# 设置显著性水平为0.05,计算左侧和右侧的临界值
alpha = 0.05
rig = 1 - alpha / 2
left = alpha / 2
# 计算样本均值的z分数
z = (xbar - mu) / (sigma / sqrt(n))
# 计算左侧和右侧的临界值对应的z分数
q1 = norm.ppf(left)
q2 = norm.ppf(rig)
# 判断样本均值的z分数是否落在临界值范围内
if q1 <= z <= q2:
print('Accept xbar = mu')
else:
print('Reject xbar != mu')
阅读全文