Statistics IIUnit 87 min read
Randomness Tests, Runs Test, Mann-Whitney U, Applications of Non-parametrics
Unit 8 of Statistics II explores randomness testing (runs test), non-parametric alternatives (Mann-Whitney U), and real-world applications of statistical randomness in quality control, survey sampling, and experimental design, with emphasis on hypothesis formulation, critical values, and decision rules at g
Key Concepts and Definitions
1. Randomness and the Runs Test
Definition: Randomness refers to the absence of patterns or systematic order in a sequence of observations. The runs test is a non-parametric method to assess whether a sequence of binary data (e.g., M/F, pass/fail) is random or contains clustering.
How it works:
- A run is a maximal sequence of identical observations. For example, in
M M F M M F, the runs areMM,F,MM,F(4 runs total). - The test compares the observed number of runs () to expected runs under randomness () and standard deviation ().
- Null hypothesis (): The sequence is random.
- Alternative hypothesis (): The sequence is not random (either too clustered or too alternating).
Formula: For a sequence of observations of type 1 (e.g., M) and of type 2 (e.g., F), the expected number of runs is: The variance is: The test statistic is: Reject if (for two-tailed test).
2. Mann-Whitney U Test (Wilcoxon Rank-Sum Test)
Definition: A non-parametric test to compare two independent samples when the data are ordinal or interval/ratio but not normally distributed. It assesses whether one sample tends to have larger values than the other.
How it works:
- Rank all observations from both samples jointly (smallest rank = 1).
- Sum the ranks for each sample ( and ).
- Calculate the U statistic for each sample: where and are sample sizes.
- The smaller value is used for the test.
- Compare to critical values from the Mann-Whitney table or use the normal approximation for large samples:
Assumptions:
- Independent samples.
- Ordinal or continuous data.
- No tied ranks (or adjust for ties).
Worked Examples
Example 1: Runs Test for Randomness
Problem:
Bank of Nepal recorded the sex of the first 30 customers as:
M M F M M F M F F M M M F F M F F M F F M F F F M F M M M F F
Test randomness at .
Solution:
- Count runs:
Sequence:
MM F MM F MMM FFF M FFF M FFF MMM FFFRuns:MM,F,MM,F,MMM,FFF,M,FFF,M,FFF,MMM,FFF→ 12 runs. - Calculate and : (M), (F).
- Expected runs:
- Standard deviation:
- Test statistic:
- Decision: Critical at (two-tailed) is . Since , fail to reject . The sequence appears random.
Example 2: Mann-Whitney U Test
Problem:
Test if satisfaction scores for Gadget A (50, 40, 30, 20) and Gadget B (40, 30, 10, 40) differ at .
Solution:
- Rank all data jointly:
Combined:
10, 20, 30, 30, 40, 40, 40, 50Ranks:1, 2, 3.5, 3.5, 5.5, 5.5, 5.5, 8(ties averaged). - Sum ranks: Gadget A: Gadget B:
- Calculate : Smaller .
- Critical value: For , , the critical at (two-tailed) is 2. Since , fail to reject . No significant difference.
Comparison Table: Runs Test vs. Mann-Whitney U
| Feature | Runs Test | Mann-Whitney U Test |
|---|---|---|
| Purpose | Test randomness in binary sequences | Compare two independent samples |
| Data Type | Binary (e.g., M/F, pass/fail) | Ordinal or continuous |
| Assumptions | No specific distribution required | Independent samples, no ties (or adjust) |
| Test Statistic | Number of runs () or -score | Rank sums () |
| Applications | Quality control, survey sampling | Medical trials, A/B testing |
| Critical Values | Tables or normal approximation | Tables or normal approximation |
Applications of Randomness and Non-parametric Tests
- Quality Control:
- Runs test checks if defects in manufacturing are randomly distributed or clustered (e.g., machine malfunction).
- Survey Sampling:
- Ensures respondents are randomly selected (e.g., alternating M/F in interviews).
- Medical Studies:
- Mann-Whitney U compares treatment effects when data are not normal (e.g., pain scores).
- Computer Science:
- Testing randomness in cryptographic sequences or simulation outputs.
- Social Sciences:
- Analyzing categorical data (e.g., voting patterns, gender distribution).
Advantages and Limitations
Runs Test
Advantages:
- Simple to compute and interpret.
- No distributional assumptions.
- Useful for detecting clustering or alternation.
Limitations:
- Only for binary data.
- Low power for small samples.
Mann-Whitney U Test
Advantages:
- Non-parametric alternative to t-test.
- Works for ordinal data.
- Robust to outliers.
Limitations:
- Less powerful than parametric tests if data are normal.
- Ties reduce test sensitivity.
Mermaid Diagrams
1. Runs Test Decision Flowchart
flowchart TD
A[Start] --> B[Count runs in sequence]
B --> C[Calculate ]
C --> D[Compute and ]
D --> E[Calculate ]
E --> F{Is ?}
F -->|Yes| G[Reject : Not random]
F -->|No| H[Fail to reject : Random]2. Mann-Whitney U Test Steps
flowchart TD
A[Start] --> B[Combine samples and rank]
B --> C[Sum ranks for each sample ]
C --> D[Calculate ]
D --> E[Take smaller ]
E --> F{Is ?}
F -->|Yes| G[Reject : Difference exists]
F -->|No| H[Fail to reject : No difference]Exam Tip
Runs Test:
- Always count runs carefully (e.g.,
MMMis one run, not three). - For large samples, use the normal approximation (-test).
- State explicitly: "The sequence is random."
- Always count runs carefully (e.g.,
Mann-Whitney U:
- Rank ties properly: Average ranks for tied values.
- For small samples, use critical value tables (e.g., from textbooks).
- Watch for one-tailed vs. two-tailed tests in the question.
Common Pitfalls:
- Incorrect : Runs test is about randomness, not "equal proportions."
- Ignoring ties: Mann-Whitney U requires tie adjustments for accuracy.
- Wrong critical values: Use from the question (e.g., 0.05, 0.01).
Exam Strategy:
- Show all steps (counting runs, ranking, calculations).
- Label hypotheses clearly (, ).
- For numerical answers, box the final test statistic (e.g., ).
Based on the TU BSc CSIT syllabus for Statistics II (STA215), unit 8.
Discussion
Loading…