# Tests of Hypothesis Involving Two Samples

• ## Comparing Two Variances via an $F$ test

• 比較兩個 Populations 的 Variances，自由度兩個族群樣本數各減一，常用 P < 0.975
• If the $F$ statistic exceeds the critical value(s), ( $P:value$ < alpha level) , $H_0$ is rejected.
• ## Comparing Two Means for Unpaired Samples

• 先以先前的 F test 測試兩個 Sample 的 Variances 是否相同
• ### Unpaired $t$ Tests with Pooled Variances

• #### Equal variances

• Pooled sample variance: $s_p^2=\frac{\left(n_1-1\right) s_1^2+\left(n_2-1\right) s_2^2}{n_1+n_2-2}$
• Making $t$ statics: $t=\frac{\left(\bar{X}_1-\bar{X}_2\right)-\left(\mu_1-\mu_2\right)}{\sqrt{s_p^2\left(\frac{1}{n_1}+\frac{1}{n_2}\right)}}$ , with $\nu=n_1+n_2-2$
• #### Unequal Population Variances

• the $t$ test must be modiﬁed into a more conservative form.
• Making $t$ statics (Welch’s approximate t or the Smith-Satterthwaite procedure.):
• $t=\frac{\left(\bar{X}_1-\bar{X}_2\right)-\left(\mu_1-\mu_2\right)}{\sqrt{\left(\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}\right)}}$ , with $\nu=\frac{\left(\frac{s_1^2}{n_1}+\frac{s_2^2}{n_2}\right)^2}{\frac{\left(\frac{s_1^2}{n_1}\right)^2}{n_1-1}+\frac{\left(\frac{s_2^2}{n_2}\right)^2}{n_2-1}}$
• ## Paired $t$ test

• Statics method: $t=\frac{\bar{X}_d-\mu_d}{\frac{s_d}{\sqrt{n_d}}}$ , with $n_d-1$ degree of freedom
• ## The Wilcoxon Rank-Sum Test for Differences in Medians

• Also known as Mann-Whitney U Test
• The populations distribution are unknown or the distributions are not normal.
• pool the $m+n: X$ and $Y$ observations to form a single sample.
• Test statistic is the sum of the ranks from the $X$ population (the smaller sample) and is denoted by $W_X$ .
• 將兩個 populations 的樣本數值混合後從小排到大，給定 rank, 然後紀錄來自於較小數目的 Population 樣本被標定的 rank 總和
• the expected value of the test statistic: $E\left(W_X\right)=\frac{m(m+n+1)}{2}$
• ## The Sign Test for Paired Data

• The elementary estimates for the paired sign test are just the observed differences $X_i - Y_i$ in pairs.
• If $H_0$ is true ( $M_X-Y$ = 0), then any particular difference $X_i-Y_i$ has probability of 1/2 of being negative or positive
• Let $S_-$ and $S_+$ denote the number of negative and positive signs.
• which have a binomial distribution if hypothesis is true
• 查表查 Cumulative Binomial Distribution, n = 樣本數，p = 0.5 代入，
• ## The Wilcoxon Signed-Rank Test for Paired Data

• 像在 One Sample 一樣從 Sign Test 延伸到 Wilcoxon Signed-Rank Test 一樣
• 將 Sample 排序後配對，並定出 Signed Rank，使用 Wilcoxon Singned-Rank Test [[One-Sample Tests of Hypothesis]]