112 年 國立中央大學工業管理研究所碩士班《統計學》

📄 試題原卷 免費註冊後即可對照原始考卷 PDF免費註冊

第 1 題15 分

Let X1,X2X_1, X_2 be independent and identically distributed random variables from N(0,1)N(0,1). Set Y1=X1/X2Y_1 = X_1/X_2.
(a) Find the probability density function (pdf) of Y1Y_1.
(b) Let Xi,i=1,…,nX_i, i = 1, \dots, n be independent random variables such that XiX_i has a continuous and strictly increasing cumulative distribution function (CDF) FiF_i. Let Yi=Fi(Xi)Y_i = F_i(X_i). Show that YiY_i are independent U(0,1)U(0,1).
(c) Show that Z=−2∑i=1nln⁡(1−Yi)Z = -2 \sum_{i=1}^{n} \ln(1-Y_i) is distributed as χ2n2\chi^2_{2n}.
Hint: χk2∼Exp(1/2)\chi^2_k \sim \text{Exp}(1/2).

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題綜合考查:

  1. 隨機變數變換與聯合密度函數。
  2. Probability Integral Transform:若 XX 的 CDF 為連續且嚴格遞增的 FF,則 F(X)∼U(0,1)F(X)\sim U(0,1)。
  3. 獨立隨機變數經各自函數變換後仍保持獨立。
  4. 指數分布與卡方分布的關係:
    χ22∼Exp⁡(12),\chi^2_2\sim \operatorname{Exp}\left(\frac12\right),
    其中 Exp⁡(λ)\operatorname{Exp}(\lambda) 採用 rate 參數化,λ=12\lambda=\frac12。
  5. 獨立卡方隨機變數之和仍為卡方分布,自由度相加。

(a) 求 Y1=X1/X2Y_1=X_1/X_2 的 pdf

解題方法

直接處理比值的變換。令

Y1=X1X2,V=X2.Y_1=\frac{X_1}{X_2},\qquad V=X_2.

則反變換為

X1=Y1V,X2=V.X_1=Y_1V,\qquad X_2=V.

由於 X1,X2X_1,X_2 為獨立的 N(0,1)N(0,1) 隨機變數,其聯合密度函數為

fX1,X2(x1,x2)=12πexp⁡{−x12+x222}.f_{X_1,X_2}(x_1,x_2) = \frac{1}{2\pi} \exp\left\{-\frac{x_1^2+x_2^2}{2}\right\}.

計算 Jacobian:

∂(x1,x2)∂(y,v)=∣vy01∣=v.\frac{\partial(x_1,x_2)}{\partial(y,v)} = \begin{vmatrix} v & y\\ 0 & 1 \end{vmatrix} =v.

因此 Jacobian 的絕對值為 ∣v∣|v|。所以 (Y1,V)(Y_1,V) 的聯合密度為

fY1,V(y,v)=12πexp⁡{−y2v2+v22}∣v∣.f_{Y_1,V}(y,v) = \frac{1}{2\pi} \exp\left\{-\frac{y^2v^2+v^2}{2}\right\}|v|.

整理得

fY1,V(y,v)=12πexp⁡{−(1+y2)v22}∣v∣.f_{Y_1,V}(y,v) = \frac{1}{2\pi} \exp\left\{-\frac{(1+y^2)v^2}{2}\right\}|v|.

對 vv 積分即可得到 Y1Y_1 的邊際密度:

fY1(y)=∫−∞∞12πexp⁡{−(1+y2)v22}∣v∣ dv.f_{Y_1}(y) = \int_{-\infty}^{\infty} \frac{1}{2\pi} \exp\left\{-\frac{(1+y^2)v^2}{2}\right\}|v|\,dv.

因為被積函數為偶函數,

fY1(y)=1π∫0∞vexp⁡{−(1+y2)v22} dv.f_{Y_1}(y) = \frac{1}{\pi} \int_0^\infty v\exp\left\{-\frac{(1+y^2)v^2}{2}\right\}\,dv.

利用

∫0∞ve−av2/2 dv=1a,a>0,\int_0^\infty ve^{-av^2/2}\,dv=\frac1a,\qquad a>0,

取 a=1+y2a=1+y^2,得到

fY1(y)=1π(1+y2),−∞<y<∞.\boxed{ f_{Y_1}(y)=\frac{1}{\pi(1+y^2)},\qquad -\infty<y<\infty }.

這正是標準 Cauchy 分布的密度,因此

Y1∼Cauchy⁡(0,1).\boxed{Y_1\sim \operatorname{Cauchy}(0,1)}.

(b) 證明 Yi=Fi(Xi)Y_i=F_i(X_i) 彼此獨立且服從 U(0,1)U(0,1)

1. 證明 Yi∼U(0,1)Y_i\sim U(0,1)

固定一個 ii。因為 FiF_i 連續且嚴格遞增,對 0<y<10<y<1,可使用其反函數 Fi−1F_i^{-1}:

P(Yi≤y)=P(Fi(Xi)≤y)=P(Xi≤Fi−1(y))=Fi(Fi−1(y))=y.\begin{aligned} P(Y_i\le y) &=P\bigl(F_i(X_i)\le y\bigr)\\ &=P\bigl(X_i\le F_i^{-1}(y)\bigr)\\ &=F_i\bigl(F_i^{-1}(y)\bigr)\\ &=y. \end{aligned}

因此 YiY_i 的 CDF 為

FYi(y)={0,y≤0,y,0<y<1,1,y≥1.F_{Y_i}(y)= \begin{cases} 0, & y\le 0,\\ y, & 0<y<1,\\ 1, & y\ge 1. \end{cases}

這正是 U(0,1)U(0,1) 的 CDF,所以

Yi∼U(0,1).\boxed{Y_i\sim U(0,1)}.

2. 證明 YiY_i 彼此獨立

對任意 y1,…,yn∈(0,1)y_1,\dots,y_n\in(0,1),

P(Y1≤y1,…,Yn≤yn)=P(F1(X1)≤y1,…,Fn(Xn)≤yn)=P(X1≤F1−1(y1),…,Xn≤Fn−1(yn)).\begin{aligned} &P(Y_1\le y_1,\dots,Y_n\le y_n)\\ &=P\bigl(F_1(X_1)\le y_1,\dots,F_n(X_n)\le y_n\bigr)\\ &=P\bigl(X_1\le F_1^{-1}(y_1),\dots, X_n\le F_n^{-1}(y_n)\bigr). \end{aligned}

由於 X1,…,XnX_1,\dots,X_n 彼此獨立,

P(Y1≤y1,…,Yn≤yn)=∏i=1nP(Xi≤Fi−1(yi))=∏i=1nyi.\begin{aligned} &P(Y_1\le y_1,\dots,Y_n\le y_n)\\ &=\prod_{i=1}^n P\bigl(X_i\le F_i^{-1}(y_i)\bigr)\\ &=\prod_{i=1}^n y_i. \end{aligned}

而每個 Yi∼U(0,1)Y_i\sim U(0,1),故

∏i=1nyi=∏i=1nP(Yi≤yi).\prod_{i=1}^n y_i = \prod_{i=1}^n P(Y_i\le y_i).

這符合獨立性的定義,因此

Y1,…,Yn 彼此獨立,且 Yi∼U(0,1).\boxed{Y_1,\dots,Y_n\text{ 彼此獨立,且 }Y_i\sim U(0,1)}.

(c) 證明 Z=−2∑i=1nln⁡(1−Yi)∼χ2n2Z=-2\sum_{i=1}^n\ln(1-Y_i)\sim\chi^2_{2n}

解題方法

先逐項處理

Wi=−2ln⁡(1−Yi).W_i=-2\ln(1-Y_i).

由於 Yi∼U(0,1)Y_i\sim U(0,1),所以

Ui=1−Yi∼U(0,1).U_i=1-Y_i\sim U(0,1).

而且因為 Y1,…,YnY_1,\dots,Y_n 彼此獨立,U1,…,UnU_1,\dots,U_n 也彼此獨立。

令

Ti=−ln⁡Ui.T_i=-\ln U_i.

對 t≥0t\ge 0,

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 2 題10 分

Let Xi,i=1,…,nX_i, i = 1, \dots, n be independent random variables such that XiX_i has a continuous and strictly increasing cumulative distribution function (CDF) FiF_i. Let Yi=Fi(Xi)Y_i = F_i(X_i).
(a) Show that YiY_i are independent U(0,1)U(0,1).
(b) Show that Z=−2∑i=1nln⁡(1−Yi)Z = -2 \sum_{i=1}^{n} \ln(1-Y_i) is distributed as χ2n2\chi^2_{2n}.
Hint: χk2∼Exp(1/2)\chi^2_k \sim \text{Exp}(1/2).

登入後即可作答並保存紀錄。

這一題的完整詳解

本題為題組題,(a) 部分已在第一題 (b) 中證明,(b) 部分已在第一題 (c) 中證明。

(a) 證明 Yi=Fi(Xi)Y_i = F_i(X_i) 獨立且服從 U(0,1)U(0,1)。
令 XX 是一個連續隨機變數,其 CDF 為 F(x)F(x),且 F(x)F(x) 是嚴格遞增的。令 Y=F(X)Y = F(X)。
我們需要計算 YY 的 CDF,即 FY(y)=P(Y≤y)=P(F(X)≤y)F_Y(y) = P(Y \le y) = P(F(X) \le y)。
由於 FF 是嚴格遞增的,存在反函數 F−1F^{-1}。
P(F(X)≤y)=P(X≤F−1(y))P(F(X) \le y) = P(X \le F^{-1}(y))。
由於 FX(x)=P(X≤x)F_X(x) = P(X \le x),所以 P(X≤F−1(y))=FX(F−1(y))P(X \le F^{-1}(y)) = F_X(F^{-1}(y))。
因為 FX(x)=F(x)F_X(x) = F(x),所以 FY(y)=F(F−1(y))=yF_Y(y) = F(F^{-1}(y)) = y。
這個結果對於 yy 在 FF 的值域內成立。由於 XX 是連續隨機變數,其 CDF F(x)F(x) 的值域是 [0,1][0,1]。
因此,Y=F(X)Y = F(X) 的 CDF 是 FY(y)=yF_Y(y) = y 對於 0≤y≤10 \le y \le 1。
這就是 U(0,1)U(0,1) 的 CDF。
所以,Yi=Fi(Xi)Y_i = F_i(X_i) 服從 U(0,1)U(0,1)。

現在證明獨立性。
令 Yi=Fi(Xi)Y_i = F_i(X_i),其中 XiX_i 是獨立的。
我們需要證明 P(Y1≤y1,Y2≤y2,…,Yn≤yn)=P(Y1≤y1)P(Y2≤y2)…P(Yn≤yn)P(Y_1 \le y_1, Y_2 \le y_2, \dots, Y_n \le y_n) = P(Y_1 \le y_1) P(Y_2 \le y_2) \dots P(Y_n \le y_n)。
P(Y1≤y1,…,Yn≤yn)=P(F1(X1)≤y1,…,Fn(Xn)≤yn)P(Y_1 \le y_1, \dots, Y_n \le y_n) = P(F_1(X_1) \le y_1, \dots, F_n(X_n) \le y_n)
由於 FiF_i 是嚴格遞增的,這等同於
P(X1≤F1−1(y1),…,Xn≤Fn−1(yn))P(X_1 \le F_1^{-1}(y_1), \dots, X_n \le F_n^{-1}(y_n))
由於 XiX_i 是獨立的,
=P(X1≤F1−1(y1))…P(Xn≤Fn−1(yn))= P(X_1 \le F_1^{-1}(y_1)) \dots P(X_n \le F_n^{-1}(y_n))
=F1(F1−1(y1))…Fn(Fn−1(yn))= F_1(F_1^{-1}(y_1)) \dots F_n(F_n^{-1}(y_n))
=y1…yn= y_1 \dots y_n
而 P(Yi≤yi)=yiP(Y_i \le y_i) = y_i (對於 0≤yi≤10 \le y_i \le 1)。
所以,P(Y1≤y1)…P(Yn≤yn)=y1…ynP(Y_1 \le y_1) \dots P(Y_n \le y_n) = y_1 \dots y_n。
因此,YiY_i 是獨立的 U(0,1)U(0,1) 隨機變數。
【答案】證明完畢。

(b) 證明 Z=−2∑i=1nln⁡(1−Yi)Z = -2 \sum_{i=1}^{n} \ln(1-Y_i) 服從 χ2n2\chi^2_{2n} 分布。
已知 Yi∼U(0,1)Y_i \sim U(0,1) 獨立。
令 Vi=−ln⁡(1−Yi)V_i = -\ln(1-Y_i)。
由於 Yi∼U(0,1)Y_i \sim U(0,1),則 Wi=1−Yi∼U(0,1)W_i = 1-Y_i \sim U(0,1) 獨立。
Vi=−ln⁡(Wi)V_i = -\ln(W_i)。
ViV_i 的 CDF 為:
FVi(v)=P(Vi≤v)=P(−ln⁡(Wi)≤v)=P(ln⁡(Wi)≥−v)=P(Wi≥e−v)F_{V_i}(v) = P(V_i \le v) = P(-\ln(W_i) \le v) = P(\ln(W_i) \ge -v) = P(W_i \ge e^{-v})。

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 3 題10 分

The moment generating function of random variable XX is defined as follows:
MX(t)=E[etX]=∫−∞∞etxf(x)dxM_X(t) = E[e^{tX}] = \int_{-\infty}^{\infty} e^{tx} f(x)dx, where f(x)f(x) is the pdf of XX.
Show that E[X2]=d2MX(t)dt2∣t=0E[X^2] = \frac{d^2 M_X(t)}{dt^2} \bigg|_{t=0}.

登入後即可作答並保存紀錄。

這一題的完整詳解

本題考查動差生成函數 (Moment Generating Function, MGF) 的性質,特別是如何利用 MGF 求取隨機變數的動差 (moments)。

核心觀念:動差生成函數對時間 tt 的微分,在 t=0t=0 時等於該隨機變數的對應動差。

解題過程:
動差生成函數的定義為 MX(t)=E[etX]M_X(t) = E[e^{tX}]。
我們要求 E[X2]E[X^2]。根據動差生成函數的性質,我們需要對 MX(t)M_X(t) 進行微分。

首先,我們計算 MX(t)M_X(t) 對 tt 的一階微分:
dMX(t)dt=ddtE[etX]\frac{dM_X(t)}{dt} = \frac{d}{dt} E[e^{tX}]
假設我們可以交換微分和期望值運算(這在 XX 的 MGF 存在且其微分也存在的條件下是成立的):
dMX(t)dt=E[ddt(etX)]\frac{dM_X(t)}{dt} = E\left[\frac{d}{dt}(e^{tX})\right]
對 etXe^{tX} 對 tt 微分,得到 XetXXe^{tX}:
dMX(t)dt=E[XetX]\frac{dM_X(t)}{dt} = E[Xe^{tX}]
現在,我們將 t=0t=0 代入上式:
dMX(t)dt∣t=0=E[Xe0⋅X]=E[X⋅1]=E[X]\frac{dM_X(t)}{dt} \bigg|_{t=0} = E[Xe^{0 \cdot X}] = E[X \cdot 1] = E[X]
這證明了 MGF 的一階微分在 t=0t=0 時等於隨機變數的期望值 E[X]E[X]。

接下來,我們計算 MX(t)M_X(t) 對 tt 的二階微分:
d2MX(t)dt2=ddt(dMX(t)dt)=ddtE[XetX]\frac{d^2 M_X(t)}{dt^2} = \frac{d}{dt} \left(\frac{dM_X(t)}{dt}\right) = \frac{d}{dt} E[Xe^{tX}]

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 4 題10 分

Suppose a civil engineer wishes to compare the strengths of two different types of beams, one (A) made of steel and the other (B) made of a different and more expensive alloy. A certain deflection (in units of 0.001 inch) was measured for each beam when submitted to a given force; thus a small deflection would indicate a beam of great strength. The order observations for the two samples of size n1=8n_1 = 8, and n2=6n_2 = 6 are the following:

TypesDeflection (in 0.001 inch)
A79, 81, 83, 84, 86, 86, 86, 87
B74, 75, 76, 77, 78, 82

(a) Please conduct a 2-samples t-test to identify whether there is a difference between the two means of deflections of different types of beams? Use α=0.05\alpha = 0.05.

Suppose there are two more different types of beams, (C) and (D), made of different alloys. The resulted sample means and sample variances of deflections from the two corresponding samples of Type C with size n3=6n_3 = 6, and of Type D with size n4=6n_4 = 6, are as following:

TypesSample sizeSample meanSample Variance
C6797.6
D6738.0

(b) Please conduct an ANOVA to identify whether there is a difference between the four means of deflections of different types of beams? Use α=0.05\alpha = 0.05, and summarize the test result in an ANOVA table.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  1. (a) 兩獨立樣本 tt 檢定:比較兩母體平均數是否相等(H0:μA=μBH_0: \mu_A = \mu_B vs. H1:μA≠μBH_1: \mu_A \neq \mu_B)。當兩組樣本變異數相近時,可採合併變異數(pooled variance)tt 檢定。
  2. (b) 單因子變異數分析(One-Way ANOVA):同時比較 k=4k = 4 組母體平均數(H0:μA=μB=μC=μDH_0: \mu_A = \mu_B = \mu_C = \mu_D vs. H1:H_1: 至少有兩組不相等),將總變異 SSTSST 分解為組間變異 SSBSSB 與組內變異 SSWSSW。

解題方法
(a) A 與 B 兩組的兩樣本 tt 檢定(α=0.05\alpha = 0.05)

  1. 計算基本統計量:
    • A 組(nA=8n_A = 8):∑xAj=79+81+83+84+86+86+86+87=672\sum x_{Aj} = 79+81+83+84+86+86+86+87 = 672,xˉA=6728=84\bar{x}_A = \frac{672}{8} = 84。
      離差平方和 SSA=(−5)2+(−3)2+(−1)2+02+22+22+22+32=56SS_A = (-5)^2 + (-3)^2 + (-1)^2 + 0^2 + 2^2 + 2^2 + 2^2 + 3^2 = 56,故 sA2=567=8.0s_A^2 = \frac{56}{7} = 8.0。
    • B 組(nB=6n_B = 6):∑xBj=74+75+76+77+78+82=462\sum x_{Bj} = 74+75+76+77+78+82 = 462,xˉB=4626=77\bar{x}_B = \frac{462}{6} = 77。
      離差平方和 SSB=(−3)2+(−2)2+(−1)2+02+12+52=40SS_B = (-3)^2 + (-2)^2 + (-1)^2 + 0^2 + 1^2 + 5^2 = 40,故 sB2=405=8.0s_B^2 = \frac{40}{5} = 8.0。
  2. 假設設定:H0:μA=μBH_0: \mu_A = \mu_B,H1:μA≠μBH_1: \mu_A \neq \mu_B,α=0.05\alpha = 0.05。
  3. 兩組樣本變異數均為 8.08.0,採合併變異數 sp2=56+408+6−2=9612=8.0s_p^2 = \frac{56 + 40}{8 + 6 - 2} = \frac{96}{12} = 8.0,檢定統計量為:
t=xˉA−xˉBsp2(1nA+1nB)=84−778(18+16)=77/3=21≈4.583t = \frac{\bar{x}_A - \bar{x}_B}{\sqrt{s_p^2\left(\frac{1}{n_A} + \frac{1}{n_B}\right)}} = \frac{84 - 77}{\sqrt{8\left(\frac{1}{8} + \frac{1}{6}\right)}} = \frac{7}{\sqrt{7/3}} = \sqrt{21} \approx 4.583
  1. 自由度 df=8+6−2=12df = 8 + 6 - 2 = 12,雙尾臨界值 t0.025,12≈2.179t_{0.025, 12} \approx 2.179。因 ∣t∣=4.583>2.179|t| = 4.583 > 2.179,拒絕 H0H_0,顯示 A、B 兩種樑的平均撓度有顯著差異(若採 Welch tt 檢定,因 sA2=sB2=8s_A^2 = s_B^2 = 8,統計量仍為 4.5834.583,自由度 df≈10.92df \approx 10.92,臨界值 t0.025,11≈2.201t_{0.025, 11} \approx 2.201,結論相同)。

(b) 四組樑之單因子 ANOVA(α=0.05\alpha = 0.05)

  1. 彙整四組統計量:
    • A:nA=8,xˉA=84,sA2=8.0n_A = 8, \bar{x}_A = 84, s_A^2 = 8.0
    • B:nB=6,xˉB=77,sB2=8.0n_B = 6, \bar{x}_B = 77, s_B^2 = 8.0
    • C:nC=6,xˉC=79,sC2=7.6n_C = 6, \bar{x}_C = 79, s_C^2 = 7.6
    • D:nD=6,xˉD=73,sD2=8.0n_D = 6, \bar{x}_D = 73, s_D^2 = 8.0
    • 總樣本數 N=8+6+6+6=26N = 8 + 6 + 6 + 6 = 26,總和 ∑∑xij=672+462+474+438=2046\sum\sum x_{ij} = 672 + 462 + 474 + 438 = 2046,總平均 xˉtotal=204626≈78.6923\bar{x}_{\text{total}} = \frac{2046}{26} \approx 78.6923。
  2. 計算平方和:
SSW=∑i=14(ni−1)si2=7(8.0)+5(8.0)+5(7.6)+5(8.0)=56+40+38+40=174SSW = \sum_{i=1}^{4} (n_i - 1)s_i^2 = 7(8.0) + 5(8.0) + 5(7.6) + 5(8.0) = 56 + 40 + 38 + 40 = 174
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 4 題10 分

(c) Following the test result in (b), we need to make comparisons between the four means, noted as pairwise-t tests. Please conduct a pairwise-t test between the two means of deflections of type A and type B with a = 0.05. Show the difference between (a) and (c).

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念
在 ANOVA 拒絕虛無假設後進行事後成對比較(pairwise tt-test / Fisher's LSD),其誤差變異數估計不再僅仰賴被比較的兩組樣本,而是使用整個 ANOVA 模型所有組別彙總的組內均方 MSWMSW,自由度亦隨之提升為 dfW=N−kdf_W = N - k。

解題方法

  1. 計算 (c) 的成對 tt 檢定統計量(α=0.05\alpha = 0.05)
    沿用 (a)、(b) 正確統計量:xˉA=84\bar{x}_A = 84、xˉB=77\bar{x}_B = 77、nA=8n_A = 8、nB=6n_B = 6,且整個 ANOVA 的 SSW=174SSW = 174、dfW=26−4=22df_W = 26 - 4 = 22,故 MSW=17422≈7.9091MSW = \frac{174}{22} \approx 7.9091。
    檢定 H0:μA=μBH_0: \mu_A = \mu_B vs. H1:μA≠μBH_1: \mu_A \neq \mu_B:
t=xˉA−xˉBMSW(1nA+1nB)=84−777.9091(18+16)=77.9091×724=72.3068≈4.609t = \frac{\bar{x}_A - \bar{x}_B}{\sqrt{MSW\left(\frac{1}{n_A} + \frac{1}{n_B}\right)}} = \frac{84 - 77}{\sqrt{7.9091\left(\frac{1}{8} + \frac{1}{6}\right)}} = \frac{7}{\sqrt{7.9091 \times \frac{7}{24}}} = \frac{7}{\sqrt{2.3068}} \approx 4.609

在 α=0.05\alpha = 0.05(未調整之單次比較水準)及自由度 dfW=22df_W = 22 下,雙尾臨界值 t0.025,22≈2.074t_{0.025, 22} \approx 2.074。因 ∣t∣=4.609>2.074|t| = 4.609 > 2.074,拒絕 H0H_0,認定 A 與 B 的平均撓度有顯著差異。

  1. 比較 (a) 與 (c) 的差異
    • 變異數估計基礎不同:(a) 的兩樣本 tt 檢定僅使用 A、B 兩組數據估計共同變異數(sp2=8.0s_p^2 = 8.0);(c) 的事後成對 tt 檢定則假設四組變異數同質,使用所有四組數據彙總的組內均方 MSW≈7.9091MSW \approx 7.9091 作為共通誤差變異數估計,估計更精確。
    • 自由度與臨界值不同:(a) 的自由度為 nA+nB−2=12n_A + n_B - 2 = 12(臨界值 2.1792.179);
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 5 題4 分

Following 10 records are used to train a Naïve Bayesian Classification model to predict tennis-playing or not, based on weather information.

DayOutlookTemperatureHumidityWindPlay Tennis
1SunnyHotHighWeakNo
2SunnyHotHighStrongNo
3OvercastHotHighWeakYes
4RainyMildHighWeakYes
5RainyCoolNormalWeakYes
6RainyCoolNormalStrongNo
7OvercastCoolNormalStrongYes
8SunnyMildHighWeakNo
9SunnyCoolNormalWeakYes
10RainyMildNormalWeakYes

(a) Let's define the event A as "play_tennis = yes", while AcA^c as "play_tennis = no". Please determine the (prior) probabilities of Pr(A)Pr(A) and Pr(Ac)Pr(A^c) by counting the frequencies based on the 10 records.

(b) Let's define the event B1B_1 as "outlook= sunny", B2B_2 as "outlook= overcast", and B3B_3 as "outlook= rainy". Please determine the conditional probabilities of Pr(Bi∣A)Pr(B_i|A) and Pr(Bi∣Ac)Pr(B_i|A^c), i=1,2,3i = 1, 2, 3, by counting the frequencies based on the 10 records. (for example, Pr(B1∣A)=1/6Pr(B_1|A)=1/6 and Pr(B1∣Ac)=3/4Pr(B_1|A^c)=3/4)
Similarly, we can define events
C1C_1 as "temperature = hot", C2C_2 as "temperature = mild", and C3C_3 as "temperature = cool";
D1D_1 as "humidity = high", and D2D_2 as "humidity = normal";
E1E_1 as "wind = weak", and E2E_2 as "wind = strong".
Assume events {Bi}\{B_i\}, {Cj}\{C_j\}, {Dk}\{D_k\}, and {El}\{E_l\} are mutually independent. Hence the Pr(Bi∩Cj∩Dk∩El)Pr(B_i \cap C_j \cap D_k \cap E_l) can be determined as Pr(Bi)⋅Pr(Cj)⋅Pr(Dk)⋅Pr(El)Pr(B_i) \cdot Pr(C_j) \cdot Pr(D_k) \cdot Pr(E_l). For example,
Pr("outlook = sunny", "temperature = cool", "humidity = normal", "wind = weak")=Pr("outlook = sunny")⋅Pr("temperature = cool")⋅Pr("humidity = normal")⋅Pr("wind = weak")=410⋅410⋅510⋅710=0.056Pr(\text{"outlook = sunny", "temperature = cool", "humidity = normal", "wind = weak"}) = Pr(\text{"outlook = sunny"}) \cdot Pr(\text{"temperature = cool"}) \cdot Pr(\text{"humidity = normal"}) \cdot Pr(\text{"wind = weak"}) = \frac{4}{10} \cdot \frac{4}{10} \cdot \frac{5}{10} \cdot \frac{7}{10} = 0.056

(c) Let's use event X as "outlook = sunny, temperature = cool, humidity = normal, wind = weak". Please determine the conditional probabilities of Pr(X∣A)Pr(X|A) and Pr(X∣Ac)Pr(X|A^c) by counting the frequencies based on the 10 records with assuming independence.

(d) Try to use Bayes' Theorem to calculate the (posterior) probabilities, Pr(A∣X)Pr(A|X) and Pr(Ac∣X)Pr(A^c|X).

(e) With the posterior probabilities in (d), would the unknown sample X be classified/predicted as "play_tennis = yes" or "play_tennis = no"?

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考查機率論與機器學習的核心基礎:單純貝氏分類器(Naïve Bayes Classifier)​與貝氏定理(Bayes' Theorem)。

  1. 事前機率(Prior Probability):在未觀測特徵前,目標類別發生的邊際機率 Pr(A)Pr(A) 與 Pr(Ac)Pr(A^c)。
  2. 條件機率與條件獨立假設(Conditional Independence Assumption):
    單純貝氏分類器的核心假設為「在給定類別的條件下,各屬性特徵彼此相互獨立」: Pr(X∣A)=Pr(B∩C∩D∩E∣A)=Pr(B∣A)⋅Pr(C∣A)⋅Pr(D∣A)⋅Pr(E∣A)Pr(X|A) = Pr(B \cap C \cap D \cap E \mid A) = Pr(B|A) \cdot Pr(C|A) \cdot Pr(D|A) \cdot Pr(E|A)
  3. 事後機率(Posterior Probability)與貝氏定理(Bayes' Theorem):
    根據全機率定理與貝氏定理,觀測到特徵向量 XX 後,屬於類別 AA 的事後機率為: Pr(A∣X)=Pr(X∣A)Pr(A)Pr(X)=Pr(X∣A)Pr(A)Pr(X∣A)Pr(A)+Pr(X∣Ac)Pr(Ac)Pr(A|X) = \frac{Pr(X|A)Pr(A)}{Pr(X)} = \frac{Pr(X|A)Pr(A)}{Pr(X|A)Pr(A) + Pr(X|A^c)Pr(A^c)}
  4. 最大事後機率準則(MAP, Maximum A Posteriori):
    比較 Pr(A∣X)Pr(A|X) 與 Pr(Ac∣X)Pr(A^c|X),將樣本分類至事後機率較大之類別。

解題方法與推導

全體樣本數為 N=10N = 10。
將 10 筆資料依照目標變數「Play Tennis」進行分類統計:

  • 類別 AA(Play Tennis = Yes):共 6 筆(Day 3, 4, 5, 7, 9, 10)。
  • 類別 AcA^c(Play Tennis = No):共 4 筆(Day 1, 2, 6, 8)。

(a) 計算事前機率 Pr(A)Pr(A) 與 Pr(Ac)Pr(A^c)

直接計算類別出現的相對頻率:

Pr(A)=n(A)N=610=0.6Pr(A) = \frac{n(A)}{N} = \frac{6}{10} = 0.6 Pr(Ac)=n(Ac)N=410=0.4Pr(A^c) = \frac{n(A^c)}{N} = \frac{4}{10} = 0.4

(b) 計算各項條件機率

計算給定 AA(共 6 筆)與給定 AcA^c(共 4 筆)之條件下,各特徵的條件機率:

  1. Outlook (BB):

    • 在 AA 中:Sunny (B1B_1) 有 1 次 (Day 9);Overcast (B2B_2) 有 2 次 (Day 3, 7);Rainy (B3B_3) 有 3 次 (Day 4, 5, 10)。 Pr(B1∣A)=16,Pr(B2∣A)=26=13,Pr(B3∣A)=36=12Pr(B_1|A) = \frac{1}{6}, \quad Pr(B_2|A) = \frac{2}{6} = \frac{1}{3}, \quad Pr(B_3|A) = \frac{3}{6} = \frac{1}{2}
    • 在 AcA^c 中:Sunny (B1B_1) 有 3 次 (Day 1, 2, 8);Overcast (B2B_2) 有 0 次;Rainy (B3B_3) 有 1 次 (Day 6)。 Pr(B1∣Ac)=34,Pr(B2∣Ac)=04=0,Pr(B3∣Ac)=14Pr(B_1|A^c) = \frac{3}{4}, \quad Pr(B_2|A^c) = \frac{0}{4} = 0, \quad Pr(B_3|A^c) = \frac{1}{4}
  2. Temperature (CC):

    • 在 AA 中:Hot (C1C_1) 有 1 次 (Day 3);Mild (C2C_2) 有 2 次 (Day 4, 10);Cool (C3C_3) 有 3 次 (Day 5, 7, 9)。 Pr(C1∣A)=16,Pr(C2∣A)=26=13,Pr(C3∣A)=36=12Pr(C_1|A) = \frac{1}{6}, \quad Pr(C_2|A) = \frac{2}{6} = \frac{1}{3}, \quad Pr(C_3|A) = \frac{3}{6} = \frac{1}{2}
    • 在 AcA^c 中:Hot (C1C_1) 有 2 次 (Day 1, 2);Mild (C2C_2) 有 1 次 (Day 8);Cool (C3C_3) 有 1 次 (Day 6)。 Pr(C1∣Ac)=24=12,Pr(C2∣Ac)=14,Pr(C3∣Ac)=14Pr(C_1|A^c) = \frac{2}{4} = \frac{1}{2}, \quad Pr(C_2|A^c) = \frac{1}{4}, \quad Pr(C_3|A^c) = \frac{1}{4}
  3. Humidity (DD):

    • 在 AA 中:High (D1D_1) 有 2 次 (Day 3, 4);Normal (D2D_2) 有 4 次 (Day 5, 7, 9, 10)。 Pr(D1∣A)=26=13,Pr(D2∣A)=46=23Pr(D_1|A) = \frac{2}{6} = \frac{1}{3}, \quad Pr(D_2|A) = \frac{4}{6} = \frac{2}{3}
    • 在 AcA^c 中:High (D1D_1) 有 3 次 (Day 1, 2, 8);Normal (D2D_2) 有 1 次 (Day 6)。 Pr(D1∣Ac)=34,Pr(D2∣Ac)=14Pr(D_1|A^c) = \frac{3}{4}, \quad Pr(D_2|A^c) = \frac{1}{4}
  4. Wind (EE):

    • 在 AA 中:Weak (E1E_1) 有 5 次 (Day 3, 4, 5, 9, 10);Strong (E2E_2) 有 1 次 (Day 7)。 Pr(E1∣A)=56,Pr(E2∣A)=16Pr(E_1|A) = \frac{5}{6}, \quad Pr(E_2|A) = \frac{1}{6}
    • 在 AcA^c 中:Weak (E1E_1) 有 2 次 (Day 1, 8);Strong (E2E_2) 有 2 次 (Day 2, 6)。 Pr(E1∣Ac)=24=12,Pr(E2∣Ac)=24=12Pr(E_1|A^c) = \frac{2}{4} = \frac{1}{2}, \quad Pr(E_2|A^c) = \frac{2}{4} = \frac{1}{2}

(c) 計算特徵事件 XX 的條件機率 Pr(X∣A)Pr(X|A) 與 Pr(X∣Ac)Pr(X|A^c)

給定事件 X=(B1∩C3∩D2∩E1)X = (B_1 \cap C_3 \cap D_2 \cap E_1),即:
「Outlook = Sunny, Temperature = Cool, Humidity = Normal, Wind = Weak」。

根據單純貝氏之類別條件獨立性:

Pr(X∣A)=Pr(B1∣A)⋅Pr(C3∣A)⋅Pr(D2∣A)⋅Pr(E1∣A)Pr(X|A) = Pr(B_1|A) \cdot Pr(C_3|A) \cdot Pr(D_2|A) \cdot Pr(E_1|A)

代入數值計算:

Pr(X∣A)=16⋅36⋅46⋅56=16⋅12⋅23⋅56=10216=5108≈0.0463Pr(X|A) = \frac{1}{6} \cdot \frac{3}{6} \cdot \frac{4}{6} \cdot \frac{5}{6} = \frac{1}{6} \cdot \frac{1}{2} \cdot \frac{2}{3} \cdot \frac{5}{6} = \frac{10}{216} = \frac{5}{108} \approx 0.0463

同理計算在 AcA^c 條件下:

Pr(X∣Ac)=Pr(B1∣Ac)⋅Pr(C3∣Ac)⋅Pr(D2∣Ac)⋅Pr(E1∣Ac)Pr(X|A^c) = Pr(B_1|A^c) \cdot Pr(C_3|A^c) \cdot Pr(D_2|A^c) \cdot Pr(E_1|A^c)

代入數值計算:

Pr(X∣Ac)=34⋅14⋅14⋅24=6256=3128≈0.0234Pr(X|A^c) = \frac{3}{4} \cdot \frac{1}{4} \cdot \frac{1}{4} \cdot \frac{2}{4} = \frac{6}{256} = \frac{3}{128} \approx 0.0234

(d) 應用貝氏定理計算事後機率 Pr(A∣X)Pr(A|X) 與 Pr(Ac∣X)Pr(A^c|X)

  1. 計算聯合機率分子項:

    Pr(X∩A)=Pr(X∣A)⋅Pr(A)=5108⋅610=5108⋅35=3108=136Pr(X \cap A) = Pr(X|A) \cdot Pr(A) = \frac{5}{108} \cdot \frac{6}{10} = \frac{5}{108} \cdot \frac{3}{5} = \frac{3}{108} = \frac{1}{36} Pr(X∩Ac)=Pr(X∣Ac)⋅Pr(Ac)=3128⋅410=3128⋅25=6640=3320Pr(X \cap A^c) = Pr(X|A^c) \cdot Pr(A^c) = \frac{3}{128} \cdot \frac{4}{10} = \frac{3}{128} \cdot \frac{2}{5} = \frac{6}{640} = \frac{3}{320}
  2. 依全機率定理計算邊際機率 Pr(X)Pr(X):

    Pr(X)=Pr(X∩A)+Pr(X∩Ac)=136+3320Pr(X) = Pr(X \cap A) + Pr(X \cap A^c) = \frac{1}{36} + \frac{3}{320}

    取分母最小公倍數 lcm(36,320)=2880\text{lcm}(36, 320) = 2880:

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

其他考古題