百分位数、离群值与箱线图

Python 中的统计思维(第 1 部分)

Justin Bois

Teaching Professor at the California Institute of Technology

ECDF 上的百分位数

ch2-2_v2.003.png

1 数据来自 Data.gov (https://www.data.gov/)
Python 中的统计思维(第 1 部分)

ECDF 上的百分位数

ch2-2_v2.004.png

Python 中的统计思维(第 1 部分)

ECDF 上的百分位数

ch2-2_v2.005.png

Python 中的统计思维(第 1 部分)

ECDF 上的百分位数

ch2-2_v2.006.png

Python 中的统计思维(第 1 部分)

计算百分位数

np.percentile(df_swing['dem_share'], [25, 50, 75])
array([ 37.3025,  43.185 ,  49.925 ])
Python 中的统计思维(第 1 部分)

2008 年美国大选箱线图

ch2-2_v2.011.png

1 数据来自 Data.gov (https://www.data.gov/)
Python 中的统计思维(第 1 部分)

2008 年美国大选箱线图

ch2-2_v2.012.png

Python 中的统计思维(第 1 部分)

2008 年美国大选箱线图

ch2-2_v2.013.png

Python 中的统计思维(第 1 部分)

2008 年美国大选箱线图

ch2-2_v2.014.png

Python 中的统计思维(第 1 部分)

2008 年美国大选箱线图

ch2-2_v2.015.png

Python 中的统计思维(第 1 部分)

2008 年美国大选箱线图

ch2-2_v2.016.png

Python 中的统计思维(第 1 部分)

绘制箱线图

import matplotlib.pyplot as plt
import seaborn as sns
_ = sns.boxplot(x='east_west', y='dem_share',
                    data=df_all_states)
_ = plt.xlabel('region')
_ = plt.ylabel('percent of vote for Obama')
plt.show()
Python 中的统计思维(第 1 部分)

开始练习吧!

Python 中的统计思维(第 1 部分)

Preparing Video For Download...