- 2071 Bhadra · 4+6 marks
Gap test algorithm; formulate poker test
Short answer
Gap test: pick target, count gaps between hits, compute F(x)=1−(1−p)^(x+1), test with K‑S or χ². Poker test: group four‑digit numbers; probabilities: all different 0.504, one pair 0.432, two pair 0.027, three of a kind 0.036, four of a kind 0.001. Compute χ²=∑(Oi−Ei)²/Ei with df=4; example with N=1000 gave χ²=1.069 < 9.488, not reject.
Write an algorithm for gap test. Formulate 4-digit poker test with suitable data with example.
Algorithm for the gap test
The gap test checks independence by examining the gaps between successive occurrences of a chosen digit. For a single digit the chance of occurrence is p = 0.1 (for an interval [α, β), p = β − α). Gap length x has probability p(1 − p)^x and cdf F(x) = 1 − (1 − p)^(x+1).
- Choose the target digit or interval [α, β).
- Scan the sequence and note each position where the target occurs. The gap is the count of non-target numbers between two consecutive occurrences.
- Group the n gaps by length (0, 1, 2, ..., and a last class "x or more").
- Find the observed relative frequencies and the cumulative function SN(x).
- Compute the theoretical F(x) = 1 − (1 − p)^(x+1).
- Compute D = max|F(x) − SN(x)| (K-S) and compare it with Dα for n gaps. Alternatively use χ0² = Σ (Oi − Ei)²/Ei with Ei = n·p(1 − p)^x.
- If the statistic is greater than the critical value, reject independence; else accept.
Four-digit poker test
The poker test treats each group of four digits like a poker hand and compares the observed counts of each pattern with the expected counts, using the chi-square test. Each random number is taken to four decimal places (e.g. 0.5127 gives digits 5, 1, 2, 7).
Probabilities of the patterns
| Pattern | Probability |
|---|---|
| All four different | 0.504 |
| One pair | 0.432 |
| Two pairs | 0.027 |
| Three of a kind | 0.036 |
| Four of a kind | 0.001 |
Probabilities are found by counting: all different = 10·9·8·7/10⁴ = 0.504; four alike = 10/10⁴ = 0.001; and so on. They sum to 1.
Steps: (1) Take N numbers and classify each into a pattern. (2) Expected count Ei = N × probability. (3) Compute χ0² = Σ (Oi − Ei)²/Ei. (4) Degrees of freedom = classes − 1 = 4. (5) Reject independence if χ0² > χ²α,4.
Example. Suppose N = 1000 four-digit numbers give these counts (data assumed for illustration):
| Pattern | Oi | Ei | (Oi − Ei)²/Ei |
|---|---|---|---|
| All different | 505 | 504 | 0.002 |
| One pair | 425 | 432 | 0.113 |
| Two pairs | 32 | 27 | 0.926 |
| Three of a kind | 37 | 36 | 0.028 |
| Four of a kind | 1 | 1 | 0.000 |
χ0² = 1.069. With α = 0.05 and df = 4, the critical value is 9.488. Since 1.069 < 9.488, we do not reject H0, and the numbers are accepted as independent.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Poker test, 10,000 five-digit numbers (2072) · Simulation and Modeling, chapter 6 · asked 4×
- Poker test, 1000 four-digit numbers (2070 Magh) · Simulation and Modeling, chapter 6 · asked 3×
- Poker test, 1000 four-digit numbers (2069) · Simulation and Modeling, chapter 6 · asked 3×
- Poker test, 10,000 five-digit numbers (2074) · Simulation and Modeling, chapter 6 · asked 2×
- Poker test, 1000 four-digit numbers (2072 Magh) · Simulation and Modeling, chapter 6
- Poker test, 10,000 four-digit values (2070) · Simulation and Modeling, chapter 6
- Cast steel ring with air gap, B-H data · Electrical Machines, chapter 1
- Short note: Routing algorithm in data communication · Telecommunications, chapter 8 · asked 2×
- Tensile test data of a steel bar · Material Science, chapter 3