假设检验总体和样本平均值
hypothesis test population and sample averages
我的人群平均体重为 5 磅。我从人群中抽取了 5879 次观察样本。样品的总重量为 410522 磅。我想弄清楚样本的平均体重是否明显高于总体。假设人口服从正态分布。我正在尝试使用统计模型中的 proportions_ztest。我不确定我是否正确使用了 counts 和 nobs 变量。有人可以告诉我我是否正确使用该功能,或者建议其他功能吗?我正在尝试获取 p 值。
代码:
import statsmodels.api as sm
cnt=410522
nbs=58759
vL=5
sm.stats.proportions_ztest(cnt,
nbs,
vL,
alternative='larger')[1]
你可以用scipy.stats.ttest_1samp(a, popmean)
得到t和p_value。
This is a two-sided test for the null hypothesis that the expected value (mean) of a sample of independent observations a
is equal to the given population mean, popmean
.
阅读更多详情 here。
如果要测试样本的平均权重是否显着高于总体,则应将 P-value/2 除以得到右尾 P_value。
我的人群平均体重为 5 磅。我从人群中抽取了 5879 次观察样本。样品的总重量为 410522 磅。我想弄清楚样本的平均体重是否明显高于总体。假设人口服从正态分布。我正在尝试使用统计模型中的 proportions_ztest。我不确定我是否正确使用了 counts 和 nobs 变量。有人可以告诉我我是否正确使用该功能,或者建议其他功能吗?我正在尝试获取 p 值。
代码:
import statsmodels.api as sm
cnt=410522
nbs=58759
vL=5
sm.stats.proportions_ztest(cnt,
nbs,
vL,
alternative='larger')[1]
你可以用scipy.stats.ttest_1samp(a, popmean)
得到t和p_value。
This is a two-sided test for the null hypothesis that the expected value (mean) of a sample of independent observations
a
is equal to the given population mean,popmean
.
阅读更多详情 here。
如果要测试样本的平均权重是否显着高于总体,则应将 P-value/2 除以得到右尾 P_value。