File tree Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change 1
- # library
2
1
import matplotlib .pyplot as plt
3
2
import numpy as np
4
3
import pandas as pd
5
4
from scipy import stats
6
5
import math
7
6
import statistics
8
7
8
+
9
+ # 今天學到五種分配,包含,
9
10
# 離散均勻分配( Discrete Uniform Distribution )
10
11
# 伯努利分配( Bernoulli Distribution )
11
12
# 二項分配(Binomial Distribution)
13
+ # 負二項分配(Negative Binomial Distribution)
14
+ # 超幾何分配(Hypergeometric Distribution)
12
15
# 今天我們透過作業中的問題,回想今天的內容吧!
13
- # 丟一個銅板,丟了100次,出現正面 50 次的機率有多大。
14
-
15
- '''
16
- 你的答案
17
- '''
18
- # 這是 bermoulli分配
19
- p = 0.5 # 假設是公平硬幣
20
- n = 100 # 重複實驗 100次,
21
- r = 50 # 計算出現50次正面
22
16
17
+ # Q1: 大樂透的頭獎,你必須從49個挑選出 6 個號碼,
18
+ # 且這六個號碼與頭獎的六個號碼一致,頭獎的機率是屬於哪一種分配?
19
+ # library
23
20
24
- # 2.計算二項分佈的概率質量分佈 (probability mass function)
25
- # 之所以稱為質量,是因為離散的點
26
- # P(X=x) --> 是機率
27
- probs = stats .binom .pmf (r , n , p )
28
- print (probs )
21
+ print ('''Q1: 大樂透的頭獎,你必須從49個挑選出 6 個號碼,
22
+ 可以想像成,大樂透中有49個號碼,6個是屬於開獎抽出的數字那一群,43個是不屬於開獎抽出的數字那一群,
23
+ 那你挑的六組號碼,有多少個是落在開獎抽出的數字那一群?
24
+ 屬於 超幾何分配.
25
+ ''' )
26
+ # Q2: 運用範例的 python 程式碼,計算大樂透的中頭獎機率?
27
+ probs = stats .hypergeom .pmf (6 ,49 ,6 ,6 )
28
+ print ("中頭獎的機率為==" ,probs )
29
+ #Q3: 你覺得電腦簽注的中獎機率,和人腦簽注相比,哪一個機率高?
30
+ print ('以機率的角度來看,兩者一樣高' )
You can’t perform that action at this time.
0 commit comments