Gap Test for Randomness
The method tests whether a sequence behaves like independent draws by looking at the gaps between successive values that fall in a chosen interval. For independent values the number of values outside the interval before the next value inside it follows a geometric distribution, so the observed counts of gap lengths are compared with the geometric expectations by a chi-square test. The interval probability can be given (for example for numbers meant to be uniform on 0 to 1) or estimated from the gaps.
선택한 구간에 들어가는 연속된 값들 사이의 간격을 살펴 수열이 독립적인 추출처럼 행동하는지를 검정합니다. 독립인 값이라면 구간 안의 다음 값이 나오기 전까지 구간 밖 값의 개수가 기하분포를 따르므로, 관측된 간격 길이별 빈도를 기하분포의 기대 빈도와 카이제곱 검정으로 비교합니다. 구간의 확률은 주어질 수도 있고(예를 들어 0과 1 사이에서 균일해야 하는 수) 간격으로부터 추정할 수도 있습니다.
Do the values in my sequence, such as random numbers or process readings, return to a given range at the intervals that independence predicts?
난수나 공정 측정값 같은 내 수열의 값들이 독립이라면 예측되는 간격으로 주어진 범위에 되돌아옵니까?
The method returns the chi-square statistic, degrees of freedom and p-value, the interval and its probability, the number of gaps, the mean gap against its expectation, and the observed and expected counts for each gap length.
When to use Gap Test for Randomness
- You check a random number generator or a sequence that should be independent.
- You suspect that values in some range come in clusters or at regular spacings.
- You want a randomness test aimed at return times rather than ups and downs.
When to use something else
- You want a test based on runs above and below the median: use Runs Test for Randomness
- You want a test based on local peaks and troughs: use Turning Point Test for Randomness
- You want a rank-based test of trend or serial dependence: use Bartels Rank Test of Randomness
Assumptions and requirements
- Under the null hypothesis the values are independent and identically distributed
- Expected counts per gap class are at least five
What the analysis reports
- Chi-square statistic, df and p-value
- Interval, its probability and whether estimated
- Observed and expected counts by gap length
- Mean gap
How to report it
A gap test on [value] values with the interval [[value], [value]) (p = [value]; [value] gaps) gave chi2([value]) = [value], p = [value].
Related methods
How this method is validated
이 방법의 검증 근거
- Independent computation. 1 reference test compares the results with SciPy at a stated tolerance of 1e-10.
독립 계산. SciPy 대조 참조 시험 1건 통과(허용오차 1e-10).
Tolerances are relative differences (absolute differences for values near zero). R comparisons and reference tests are re-run before each release of the analysis engine.
허용오차는 상대 차이입니다(0 근처 값은 절대 차이). R 대조와 참조 시험은 분석 엔진을 배포할 때마다 다시 돌립니다.
Run Gap Test for Randomness on Quorant
- Data you need
- a table (CSV or Excel) with an outcome variable
- Price
- 250 credits for one analysis up to 10,000 rows (complexity level 2); larger or wider data costs more. Optional methodologist review: 1200 credits.
- Checking
- Compared with independent computations
- Before you pay
- A free pre-analysis diagnosis checks your data and gives an exact quote; nothing is deducted until you approve it.