正态性检验
许多常用的假设检验都属于一套功能强大的统计工具,但它们依赖一个前提:数据近似服从正态分布。直方图可以让我们初步判断数据是否近似正态,但各种假设检验能让我们直接检验这一假设。而且,当样本量较小时,直方图对分箱数量非常敏感。
在本练习中,您将使用 salary_df 中奥斯汀市员工的工资数据,重点关注西语裔消防员。您将使用 Anderson–Darling 假设检验,分析其工作年限是否近似服从正态分布。
本练习是课程的一部分
Python 推断基础
练习说明
- 绘制员工
Years of Employment的直方图。 - 进行 Anderson–Darling 正态性检验,查看
Years of Employment是否近似正态分布。 - 找出检验
statistic大于哪些critical_values。 - 打印在这些
significance_level下原假设会被拒绝。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Plot a histogram of the employees' "Years of Employment"
____.plot(kind="____")
plt.show()
# Conduct an Anderson-Darling test using the years of employment from salary_df
result = stats.____(____)
# Print which critical values the test statistic is greater than the critical values
print(result.____ > result.____)
# Print the significance levels at which the null hypothesis is rejected
print(result.____[result.____ > result.____])