###### tags: `111-2學校上課`
# 機率
## syllabus
```
機率 Probability
Prerequisites: Calculus
Course Outlines:
1. Introduction – Motivation –Axioms of Probability
2. Combinatorial Analysis
3. Conditional Probability and Independence
4. Discrete Random Variables
5. Special Discrete Random Variables
6. Continuous Random variables
7. Special Continuous Random Variables
8. Two-dimensional Random Variables
9. Limit Theorems
10. (if time allowed) Correlation, Covariance, Conditional Expectation
11. (if time allowed) Discrete Time Markov Chain
Grading bases:
1. Homework Sets + Class Participation 20%
2. Two Mid Terms 25%*2=50%
3. Final Exam. 30%
Textbook: Ghahramani, “Fundamentals of Probability with Stochastic Processes,” 3rd
ed., Pearson, 2005 (or PNIE edition, 2014), or 4th ed., CRC Press, 2019.
References:
1. S. Ross, “A First Course in Probability”, 8th ed., Pearson Prentice
Hall, 2010.
2. Leon-Garcia, “Probability, Statistics, and Random Processes for
Electrical Engineering,” 3rd ed., Pearson, 2009.
3. Yates and Goodman, “Probability and Stochastic Processes,” 3rd
ed., John Wiley & Sons, 2015.
4. Papoulis and Pillai, “Probability, Random Variables, and Stochastic
Processes,” 4th ed., Mc-Graw-Hill, 2002.
5. Walpole, Myers, Myers and Ye, “Probability and Statistics for
Engineers and Scientists,” 9th ed., Pearson, 2014
```
## ppt
https://drive.google.com/drive/folders/1A-5L9KckWdgCMIrjSCEjJQY4uVmWiz0D?usp=sharing
## 課程
---
### 2/21 week1(二)
書籍:機率思考
內容:課程大綱講解
### 2/22
#### Chapter1
| 名稱 | 意義 |
|:-------------------------------------------------- | -------------------------------------- |
| relative frequency interpretation | 實際操作多次 分析最後結果 得到近似機率 |
| successfully axiomatized the theory of probability | |
| | |
#### Sample space and events
Experiment(實驗):Tossing a die
Outcome(結果):sample point | element
Sample space(樣本空間):{all outcome}(finite 有限的)
Event:Subset of sample sapce
##### ex1 Tossing a die
sample space={H,T} ***H(ead),T(ail)***
##### ex2 Tossing a die + filping a conin
flipping a coin and tossing a die if T(ail) or flipping a coin again if H(ead)
```
if coin == Tail
Tossing a die
else
Filping a coin
```
Sample Space={T1,T2,T3,T4,T5,T6,HT,HH}
##### ex3 Measuring the lifetime of a lightbult(描述燈泡生命週期)
S={x:x>=0}
E={x: x 100} is the event that the light bulb lasts **at least 100 hours**
#### Sample Space and Event
屬於:$E \subset F$
連集:$EF = E \bigcup F$
差集:$E-F = E \bigcap F$
捕集:$E^C = S-E$
#### Axioms of probability
Axiom 1:P(A)>=0 A發生的機率大於等於0
Axiom 2:P(S)= 1 樣本空間發生機率為1
Axiom 3:If $P(\bigcup^{\infty}_{i=1}A_i)=\sum_{i=1}^{\infty}P(A_i)$
當 有很多互斥的event 結果機率相加 = 全部各自機率相加
**mutually exclusive 事件跟條件 互斥
ex 同一時間 一顆骰子 不可出現兩種不同結果**
---
### 3/1
#### Theorem 1.3
$P(A) = N(A) / N(S) A\\N(S) \text{is sample point are equally likely to occur}\\N(A) \text{is number point are equally likely to occur}$
#### theorem 1.6

$P(A \bigcup B) = P(A)+P(B)-P(AB)$
---
### 3/7
#### HW
Due Time:3/13 23:59
- [ ] 是否完成
[注意事項](https://drive.google.com/file/d/1fHt6D9snbRzIror09LgAa3-IvGzppWJO/view?usp=sharing)
[功課](https://drive.google.com/file/d/1g3jE7DvPbyyPkcC-C_oPB2KE3pkkidBr/view?usp=sharing)
#### 1.4 Basic Theorem
##### Theorem1.7
$P(A) = P(AB)+P(AB^c)$


公式
$P(A_1 \bigcup A_2\bigcup A_3\bigcup...\bigcup A_n)= \sum P(A_i)-\sum P(A_i A_j)+\sum P(A_i A_j A_k)+(-1)^{n-1}P(A_1 A_2 ...A_n)$
#### 1.6 probabilities 0 and 1
##### ex selecting a random point form (0,1)
**在樣本數量為無限時 1的機率不代表樣本空間 0的機率不代表部會發生**
$A = {1/3},P(A)=A$
$B=(0,1)-A,P(B)=B$
#### 1.7 Random selectuion of points form intervals
$ex1:\\
\text{(1.5,5.8) choose a point in (2.5,4.3)}\\
P=(4.3-2.5)/(5.8-1.5) = 1.8/3.4=18/43\\
ex2:
\text{(1.2,5.2) choose x,y a point in x+y <4} \\
\ \text{first we know 2.4<x+y<10.4} \\
\text{Error Thinking P = (4-2.4)/(10.4-2.4)}
\\為何呢 因為他把所有相加數字的可能性都為一樣,但2.4只能有一個1.2+1.2的解法
\\但是3.9卻有無限種解法 所以不能使用這個公式 因為這公式前提是 機率分布平均\\
正確方法=\frac{((4-2.5)^2*\frac{1}{2})}{((4.3-2.5)*(4.3-2.5))}$
### Charpter 2 Combinatiorial Method
$\text{Ex2.1 How many outcomes are there if we throw 5 dice? Ans: }N(S) = 6*6*6*6*6 = 6^5$
$\text{Ex2.2 How many outcomes are there if at least one 3 among these 4 dice
? Ans:}\\ N(S) = 6*6*6*6 = 6^4;N(A^c)=5*5*5*5=5^4$
$\text{Ex2.6 How many outcomes are there if at least among n people have the same bitrhday? Ans:} \\N(S) = 365*365*365*365 = 365^4 \\ N(A^c)=365(隨便選個日期)*364(不能跟前面重複)*363*....*(365-n+1))\\
P(A)=N(A^c)/N(S);P(A)=1-P(A^c)$
#### Theorem 2.3
$S={1,2,3,4,5,6};n=6 \\\text{subset possible} {(空的,1),(空的,2),(空的,3),(空的,4),(空的,5),(空的,6)} = 2^6$
$\text{Ex2.8 B and J play chess until tow game in row(連贏兩次)}$
$p(S)=(1/2)(1/2)+(1/2)(1/2)(1/2)+....= \frac{\frac{1}{2}}{1-\frac{1}{2}^n}$
#### 2.3 Permutatuions(排序)
$P_r^n=P(n,r)=n*(n-1)*(n-2)...*(n-r+2)=\frac{N!}{(N-R)!} \\ P_n^n=P(n,n)=n*(n-1)*(n-2)...*(1)=N!$
$\text{Ex 2.11 2 electronics, 4 computer science, 3 statistics
,3 biology, and 5 music books are
put on a bookshelf with a random arrangement. What is the probability that the books of the same subject are together?}\\
Ans: N(S) = 17 ! ; N(A) = 5!(五個種亂排) * (2!*4!*3!*3!*5!)(每種書再一起 但順序隨機)$
$\text{EX extra1: 5個黑球 2個黃球 3顆黑球? 排成一列 有多少可能性}\\
Ans:\frac{10!(全部亂排)}{5!(亂排後 相同顏色球交換一樣)*2!(亂排後 相同顏色球交換一樣)*3!(亂排後 相同顏色球交換一樣)}$
$\text{EX extra2: How many different letter arrangements can be formed using the letter P E P P E R ?}\\
Ans:\frac{6!(全部亂排)}{3!(亂排後 相同字母交換一樣)*2!(亂排後 相同字母交換一樣)*1!(亂排後 相同字母交換一樣)}$
#### 2.4 Combinations(組合)
Definition: An unordered arrangement of $r$ objects from a set of
$A$ containing $n$ objects is called an $r$-element combination of $A$, or a
combination of the elements of $A$ taken $r$ at a time. The number of $r$-element
combinations of a set containing $n$ objects is denoted by $\binom{n}{r}$.
$\binom{n}{r}=\frac{n!}{r!(n-r)!}=\frac{P^n_r}{r!}$
#### sp
**$\binom{n+1}{r}=\binom{n}{r}+\binom{n}{r-1}$**
#### problem
$\text{Ex 2.16 In how many ways can 2 math and 3 biology books be selected from 8 math and 6 biology books?}$
$Ans:\binom{8}{2}*\binom{6}{3}$
八本書裡取兩本(不管順序)*六本書裡取三本(不管順序)
$\text{Ex 2.17 45 instructors were selected randomly to ask whether they are happy with their teaching loads. The response of 32 were negative. If Drs. Smith, Brown, and Jones were among those questioned. P(all 3 gave negative responses)=?}$
$Ans:\binom{42}{29}/\binom{45}{32}$
N(S)=$\binom{45}{32}$
N(A)=$\binom{42}{29}先從42找人出來回復29否定,然後剩下的人我們他們都是正向$
$\text{Ex:有一個盒子,其中有25個球,其中11個是白色的,8個是黑色的,其餘是黃色的 。從盒子中隨機抽出5個球。求:(a) 5個球全是黑色的機率是多少?(b) 5個球顏色都相同的機率是多少??}$
N(S)=$\frac{25!}{11!*8!6!}$
$Ans(a):\binom{8}{5}/\binom{25}{5}$
$Ans(b):\binom{8}{5}/\binom{25}{5}+\binom{11}{5}/\binom{6}{5}+\binom{8}{5}/\binom{25}{5}$
$\text{Ex 2.19 In the lottery game, players pick 6 integers from 1 to 49, order of selection being irrelevant. (a) P(grand prize = 6 matches)=? (b) P(2 nd prize = 5 matches)=? (c) P(3 rd prize = 4 matches)=?}$
$Ans(a):\frac{1}{\binom{49}{6}}$
$Ans(b):\frac{\binom{6}{5}*\binom{43}{1}}{\binom{49}{6}}$
$Ans(b):\frac{\binom{6}{4}*\binom{43}{2}}{\binom{49}{6}}$
$\text{Ex 2.20 7 cards are drawn from 52 without replacement. P( at least one of the cards is a king)=? Hint: Compute P(none of the cards is a king) first}$
$Ans(a):\frac{\binom{48}{7}}{\binom{52}{7}}$
$\text{Ex 2.21 5 cards are drawn from 52. P(full house)=? }$
$Ans(a):13*12*\binom{4}{3}*\binom{4}{2}$
### Theorem 2.5 (Binomial Theorem; Binomial expansion):
For any real numbers $a$ and $b$ and any nonnegative integer $n$,
$$(a + b)^n = \sum_{k=0}^{n} \binom{n}{k} a^{n-k} b^k.$$
#### problem
$\text{Ex 2.25 What is the coefficient of}$
$x^2 y^3$ $\text{in the expansion of }$$(2x+3y)^5$?
$Ans(a):\binom{5}{2}*2^2*3^3$
$\binom{2n}{n}= sum^n_{i=0}{ \binom{n}{i}^2}$
$x^2 y^3$ $\text{in the expansion of }$$(2x+3y)^5$?
$Proof: \binom{2n}{n} = sum^n_{i=0}{ \binom{n}{i}^2}$
### 1 1 3. Conditional Probability and Independence p2. 3.1 Conditional probability(條件機率)
### 2023/3/21(二)
The conditional probability of A given B, denoted by P(A|B), is defined as:
P(A|B) = P(A ∩ B) / P(B)

#### problem
**Ex 3.1** In a certain region of Russia, P(one lives at least 80)=0.75, P(one lives at least 90)=0.63. What is the probability that a randomly selected 80-year-old person from this region will survive to become 90 用latex in hackmd
$Ans(a):P(A|B)=P(AB)/P(B)=P(A)/P(B)=0.63/0.75=0.84$
**Ex 3.2**從所有有兩個孩子的家庭中隨機選擇一個家庭,發現他們有一個女孩。該家庭另一個孩子是女孩的概率是多少?假設在一個有兩個孩子的家庭中,所有性別分配都是等概率的。
$Ans(a):P(A|B)=P(AB)/P(B)=P(A)/P(B)=0.25/0.75=0.3333$
**Ex 3.5**從一副52張撲克牌中抽取8張牌。已知其中3張是黑桃,求另外5張牌都是黑桃的概率是多少?
$Ans(a):P(A|B)=P(AB)/P(B)=P(A)/P(B)=\frac{\binom{13}{8}}{\binom{13}{3}*\binom{39}{5}}$

**Ex 3.9**假設有5個良好的保險絲和2個有瑕疵的保險絲混在一起。為了找出有瑕疵的保險絲,我們進行逐一測試,隨機且不重複地進行。在前兩次測試中都找到有瑕疵的保險絲的機率是多少??
$Ans(:P(D 1 )P(D 2 |D 1 ) =2/7x1/6=1/21$
**Ex 3.11**Suppose 5 good fuses and 2 defective ones have been mixed up. To find the defective fuses, we test them 1-by-1, at random and without replacement . What is the probability that we find both of the defective fuses in exactly three tests?
$Ans(:P(D1)P(D2|D1)P(D3|D1D2) =2/7x1/6*0/5 = 0$
**Ex 3.12**An insurance company rents 35% of the cars for its customers from agency I and 65% from agency II. If 8% of the cars of agency I and 5% of the cars of agency II break down during the rental periods, what is the probability that a car rented by this insurance company breaks down?
$Ans:0.08*0.35+0.05*0.65$
### 3.3
#### 3.14
> 2個賭徒玩“正反面”的遊戲。當硬幣正面朝上時,玩家A從B贏得1美元,反之,玩家B從A贏得1美元。假設玩家A最初有a美元,玩家B有b美元。如果他們繼續玩這個遊戲,那麼以下事件的機率是多少:?
sol:
$P(E)=p_i;帶表有i塊錢$
$P_i=(\frac{1}{2}p_{i-1}+\frac{1}{2}p_{i+1});帶表有i塊錢$
$P(E)=p_i;帶表有i塊錢$
$P_0 = 1$
$P_{a+b} = 0$
#### 3.15
假設大學中有30%的學生是大一新生,25%是大二學生,25%是大三學生,20%是大四學生。此外,80%的大四學生,70%的大三學生,50%的大二學生和30%的大一新生經常使用校園圖書館。那麼所有學生中有多少百分比經常使用圖書館呢?
$P(A)=P(A|F)P(F)+P(A|O)P(O) +P(A|J)P(J)+P(A|E)P(E) =(0.30)(0.30)+(0.50)(0.25) +(0.70)(0.25)+(0.80)(0.20) =0.55$
#### 3.4 Bayes’ formula: Example
Ex: In a toy factory, 30%, 50%, and 20% of production is manufactured by machines I, II, and III, respectively. If 4, 5, and 3% of the output of these respective machines is defective, what is the probability that a randomly selected toy that is found to be defective is manufactured by machine III?
$0.3*0.04+0.5*0.05+0.2*0.03=0.043缺陷$
$0.2*0.03/0.043= 0.139534883721$
Ex 3.21 一個盒子裡有7個紅球和13個藍球。從盒子中隨機取出2個球並在不看顏色的情況下丟棄。如果再從盒子中隨機取出一個球,觀察到是紅色的,那麼被丟棄的兩個球都是藍色的概率是多少?
$2藍0紅=\frac{13}{20}*\frac{12}{19}$
$1藍1紅=\frac{13}{20}*\frac{7}{19}$
$0藍2紅=\frac{7}{20}*\frac{6}{19}$
第三球(7/18)(39/95)/ [(7/18)(39/95)+(6/18)(91/190)+(5/18)(21/190)] =0.46
在实际存在某种疾病时,实验室血液检测方法的检出率为95%。但是,在对健康人进行测试时,该检测方法也会产生1%的假阳性结果。如果人群中实际上有0.5%的人患有该疾病,那么当测试结果为阳性时,一个人患有该疾病的概率是多少?
### 4/18
#### Charpter 4
$s: X(s) \in I$
#### 4.2 Disribution function
$$ F_X(t) = F(t) = P(X \leq x) $$
$$ F(y) = P(Y \leq y) = \sum_{i=1}^y p_i $$
| Event concerning X | Probability of the event in terms of F | Event concerning X | Probability of the event in terms of F |
| ------------------ | -------------------------------------- | ------------------ |:-------------------------------------- |
| X ≤ a | F(a) | X ≤ a | FX ≤ F(a) |
| a < X ≤ b | F(b) - F(a) | a < X ≤ b | F(b) - F(a) |
| X > a | 1 - F(a) | X > a | 1 - F(a) |
| X < a | F(a-) | X >= a | FX ≥ F(a-) |
| X ≥ a | 1 - F(a-) | X < b | FX < F(b) |
| X = a | F(a) - F(a-) | X = a | FX = F(a) - F(a-) |
##### ex