连续型分布

Python 统计学入门

Maggie Matsui

Content Developer, DataCamp

等公交

下午 1 点至 2 点的时间轴,公交每 12 分钟一班,共 6 班

Python 统计学入门

连续型均匀分布

坐标轴,x 轴为等待时间

Python 统计学入门

连续型均匀分布

Y 轴为 P(outcome = wait time),图中横线为 1/12

Python 统计学入门

概率仍等于面积

$$P(4 \le \text{wait time} \le 7) = ~~ ?$$

4 到 7 之间的区域在横线下被高亮

Python 统计学入门

概率仍等于面积

$$P(4 \le \text{wait time} \le 7) = ~~ ?$$

高亮区域宽度为 7-4=3,高度为 1/12

Python 统计学入门

概率仍等于面积

$$P(4 \le \text{wait time} \le 7) = 3 \times 1/12 = 3/12$$

高亮区域宽度为 7-4=3,高度为 1/12

Python 统计学入门

Python 中的均匀分布

$$ P(\text{wait time} \le 7)$$

从 0 到 7 下方区域被高亮

from scipy.stats import uniform

uniform.cdf(7, 0, 12)
0.5833333
Python 统计学入门

"大于"型概率

$$ P(\text{wait time} \ge 7) = 1 - P(\text{wait time} \le 7)$$

从 7 到 12 的区域被高亮

from scipy.stats import uniform
1 - uniform.cdf(7, 0, 12)
0.4166667
Python 统计学入门

$$ P(4 \le \text{wait time} \le 7)$$

从 4 到 7 的区域被高亮

Python 统计学入门

$$ P(4 \le \text{wait time} \le 7)$$

从 0 到 7 的区域被高亮

Python 统计学入门

$$ P(4 \le \text{wait time} \le 7)$$

0–4 区域浅色高亮,4–7 区域深色高亮

from scipy.stats import uniform
uniform.cdf(7, 0, 12) - uniform.cdf(4, 0, 12)
0.25
Python 统计学入门

总面积 = 1

$$P(0 \le \text{wait time} \le 12) = ~~ ?$$

分布宽度 = 1,高度 = 1/12

Python 统计学入门

总面积 = 1

$$P(0 \le \text{outcome} \le 12) = 12 \times 1/12 = 1$$

分布宽度 = 1,高度 = 1/12

Python 统计学入门

按均匀分布生成随机数

from scipy.stats import uniform
uniform.rvs(0, 5, size=10)
array([1.89740094, 4.70673196, 0.33224683, 1.0137103 , 2.31641255,
       3.49969897, 0.29688598, 0.92057234, 4.71086658, 1.56815855])
Python 统计学入门

其他连续型分布

 

双峰分布

 

钟形曲线分布

Python 统计学入门

其他连续型分布

 

曲线下高亮区域,文字:area = 1

 

钟形曲线下高亮区域,文字:area = 1

Python 统计学入门

其他特殊分布类型

正态分布

正态分布图

指数分布

指数分布图

Python 统计学入门

Passons à la pratique !

Python 统计学入门

Preparing Video For Download...