1. **Problem:** Test if two quality control labs have the same samples using three non-parametric tests at 5% significance level.
**Given data:**
Lab A defects: 9, 3, 1, 3, 0, 7, 2, 11
Lab B defects: 12, 6, 6, 4, 8, 5, 4, 0
---
### i. Median Test
1. **State hypotheses:**
- Null hypothesis $H_0$: The two labs have the same median number of defects.
- Alternative hypothesis $H_1$: The medians differ.
2. **Find combined median:**
Combine all data: 0,0,1,2,3,3,4,4,5,6,6,7,8,9,11,12
Sorted combined data median is average of 8th and 9th values:
$$\text{Median} = \frac{4 + 5}{2} = 4.5$$
3. **Classify each observation as above or below median:**
- Lab A: Above median (9,7,11), Below median (3,1,3,0,2)
- Lab B: Above median (12,6,6,8,5), Below median (4,4,0)
4. **Construct contingency table:**
| | Above Median | Below Median |
|-----------|--------------|--------------|
| Lab A | 3 | 5 |
| Lab B | 5 | 3 |
5. **Calculate test statistic:**
Use chi-square test for independence:
$$\chi^2 = \sum \frac{(O - E)^2}{E}$$
Expected counts:
- Total above median = 8
- Total below median = 8
- Total Lab A = 8
- Total Lab B = 8
Expected for Lab A above median = $\frac{8 \times 8}{16} = 4$
Similarly for others.
Calculate:
$$\chi^2 = \frac{(3-4)^2}{4} + \frac{(5-4)^2}{4} + \frac{(5-4)^2}{4} + \frac{(3-4)^2}{4} = 1$$
6. **Decision:**
Degrees of freedom = 1
Critical value at 5% = 3.841
Since $1 < 3.841$, fail to reject $H_0$.
**Conclusion:** No significant difference in medians.
---
### ii. Mann-Whitney U Test
1. **State hypotheses:**
- $H_0$: The distributions of defects are the same.
- $H_1$: The distributions differ.
2. **Rank all 16 observations combined:**
Ranks assigned from smallest to largest, average ranks for ties.
3. **Sum ranks for each lab:**
Calculate $R_A$ and $R_B$.
4. **Calculate U statistics:**
$$U_A = n_A n_B + \frac{n_A(n_A+1)}{2} - R_A$$
$$U_B = n_A n_B - U_A$$
5. **Calculate mean and standard deviation of U:**
$$\mu_U = \frac{n_A n_B}{2}$$
$$\sigma_U = \sqrt{\frac{n_A n_B (n_A + n_B + 1)}{12}}$$
6. **Calculate z-score:**
$$z = \frac{U - \mu_U}{\sigma_U}$$
7. **Decision:**
Compare $|z|$ to critical z-value 1.96 at 5% significance.
**(Detailed rank calculations omitted here for brevity but done in full solution.)**
Result: $|z| < 1.96$, fail to reject $H_0$.
**Conclusion:** No significant difference between labs.
---
### iii. Wald-Wolfowitz Runs Test
1. **State hypotheses:**
- $H_0$: The two samples come from the same distribution.
- $H_1$: They differ.
2. **Combine and order data:**
Label each observation by lab and sort by defect count.
3. **Count runs:**
A run is a sequence of identical labels.
4. **Calculate expected runs and variance:**
$$E(R) = \frac{2 n_A n_B}{n_A + n_B} + 1$$
$$Var(R) = \frac{2 n_A n_B (2 n_A n_B - n_A - n_B)}{(n_A + n_B)^2 (n_A + n_B - 1)}$$
5. **Calculate z:**
$$z = \frac{R - E(R)}{\sqrt{Var(R)}}$$
6. **Decision:**
Compare $|z|$ to 1.96.
**Result:** $|z| < 1.96$, fail to reject $H_0$.
**Conclusion:** No evidence to say samples differ.
---
**Final summary:** All three tests fail to reject the null hypothesis at 5% significance level, indicating no significant difference between the two labs' samples.
Lab Sample Tests Bfa429
Step-by-step solutions with LaTeX - clean, fast, and student-friendly.