Anscombe’s quartet - 安斯库姆四重奏 是四组基本的统计特性一致的数据,但它们的分布却非常不同。
性质
数值
9
x的方差
11
y的平均数
7.50(精确到小数点后两位)
y的方差
4.122或4.127(精确到小数点后三位)
x与y之间的相关系数
0.816(精确到小数点后三位)
y=3.00+0.500x(分别精确到小数点后两位和三位)
让我们使用Python和seaborn库、Ciw库 etc. 来探索一下吧
引入库
import pandas as pd # Data manipulation
import ciw # The discrete event simulation library we will use to study queues
import matplotlib.pyplot as plt # Plots
import seaborn as sns # Powerful plots
from scipy import stats # Linear regression
import numpy as np # Quick summary statistics
import tqdm # A progress bar
缺少相应库使用pip install即可
加载Anscombe数据集
anscombe = sns.load_dataset("anscombe")
我们得到四组数据集,每组由11个(x, y)点构成:
dataset x y
0 I 10.0 8.04
1 I 8.0 6.95
2 I 13.0 7.58
3 I 9.0 8.81
4 I 11.0 8.33
5 I 14.0 9.96
6 I 6.0 7.24
7 I 4.0 4.26
8 I 12.0 10.84
9 I 7.0 4.82
10 I 5.0 5.68
11 II 10.0 9.14
12 II 8.0 8.14
13 II 13.0 8.74
14 II 9.0 8.77
15 II 11.0 9.26
16 II 14.0 8.10
17 II 6.0 6.13
18 II 4.0 3.10
19 II 12.0 9.13
20 II 7.0 7.26
21 II 5.0 4.74
22 III 10.0 7.46
23 III 8.0 6.77
24 III 13.0 12.74
25 III 9.0 7.11
26 III 11.0 7.81
27 III 14.0 8.84
28 III 6.0 6.08
29 III 4.0 5.39
30 III 12.0 8.15
31 III 7.0 6.42
32 III 5.0 5.73
33 IV 8.0 6.58
34 IV 8.0 5.76
35 IV 8.0 7.71
36 IV 8.0 8.84
37 IV 8.0 8.47
38 IV 8.0 7.04
39 IV 8.0 5.25
40 IV 19.0 12.50
41 IV 8.0 5.56
42 IV 8.0 7.91
43 IV 8.0 6.89
查看统计数据
anscombe.groupby("dataset").describe()
得到非常相近的结果
x y
dataset
I count 11.000000 11.000000
mean 9.000000 7.500909
std 3.316625 2.031568
min 4.000000 4.260000
25% 6.500000 6.315000
50% 9.000000 7.580000
75% 11.500000 8.570000