We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7566e23 commit 212e060Copy full SHA for 212e060
D28_Binomial/homework.py
@@ -0,0 +1,28 @@
1
+# library
2
+import matplotlib.pyplot as plt
3
+import numpy as np
4
+import pandas as pd
5
+from scipy import stats
6
+import math
7
+import statistics
8
+
9
+# 離散均勻分配( Discrete Uniform Distribution )
10
+# 伯努利分配( Bernoulli Distribution )
11
+# 二項分配(Binomial Distribution)
12
+# 今天我們透過作業中的問題,回想今天的內容吧!
13
+# 丟一個銅板,丟了100次,出現正面 50 次的機率有多大。
14
15
+'''
16
+你的答案
17
18
+# 這是 bermoulli分配
19
+p = 0.5 # 假設是公平硬幣
20
+n = 100 # 重複實驗 100次,
21
+r = 50 # 計算出現50次正面
22
23
24
+# 2.計算二項分佈的概率質量分佈 (probability mass function)
25
+# 之所以稱為質量,是因為離散的點
26
+# P(X=x) --> 是機率
27
+probs = stats.binom.pmf(r, n, p)
28
+print(probs)
0 commit comments