連續型機率分佈

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 統計學入門

一起來練習吧!

Python 統計學入門

Preparing Video For Download...