ADescribe · Guide test 262
Rao spacing test
Tests circular uniformity using departures of angular spacings from equal spacing.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Tests of circular uniformity (Rayleigh, V, Kuiper, Watson, Rao) — Are the directions or times spread evenly round the circle, or do they prefer some directions?
In Tests of circular uniformity (Rayleigh, V, Kuiper, Watson, Rao), choose Test = Rao spacing.
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Rao spacing test
Large spreads approach a uniform circle.
Your data
Drag a point or use ↑/↓ to change itSectors are area-proportional counts; the arrows point to each mean direction, with length R̄ (0: no preferred direction, 1: all identical). The colored arcs are the gaps Rao's test compares with 360/n.
If H₀ were true
- The reference: how U varies across samples when H₀ is true, simulated: 9,999 uniform samples of 30 (Monte Carlo: 9,999 uniform samples on the shared stream).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .102).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- the gap from each direction to the next, going round the circle
- the gap if the directions were perfectly even
- compared with Monte Carlo draws of uniform samples on the shared stream (the curve)
The verdict
U = 150.02, p = .102
p > α = .050: compatible with H₀
Sensitive to clumps and holes of any shape, including multimodal patterns; its Monte Carlo p moves slightly with the number of draws.
- Statistic
- 150.021
- p-value
- 0.1025
Rao spacing test on Directions (°): n = 30: U = 150.02, p = .102. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0: angular observations are uniform on the circle.
Assumptions
Independent angular observations with a clear radians/degrees convention and orientation. The usual null uses a full circular domain; axial data require an appropriate doubling transformation or axial model.
Formula
Parameters and notation
Di=θ(i+1)−θ(i), with θ(n+1)=θ(1)+2π. The expected equal spacing is 2π/n.
Structure of the method
Sort angles around the complete circle, include the wraparound gap from the final observation back to the first, compare every circular spacing with the equal-spacing benchmark, and sum absolute deviations. Omitting the closing gap changes the statistic and destroys its intended circular interpretation.
Estimated and nuisance parameters
Estimate the ordered gaps and their discrepancy; no mean direction, concentration, or regression coefficient is fitted. Equal expected spacing under uniform sampling does not mean observed uniform samples should be regularly spaced. The simulated distribution accounts for random uneven gaps rather than comparing the statistic with zero.
Settings and design choices
Choose units, tie/rounding treatment, finite-sample table or simulation calibration, and alpha if a table decision is requested. Multiplying radians into degrees changes the numeric statistic and requires matching critical values. The circular implementation may provide p-value ranges/decisions from tabulated values, not an exact continuous p value.
Fitting and adaptation
Adapt by applying the same circular-gap and measurement-resolution procedure to simulated null samples of equal size. If observations are clustered by subject or time, use a justified dependence-aware alternative. Data-driven smoothing or jittering of ties changes the observed process and should not be used solely to obtain a preferred significance result.
Sensitivity and robustness
Inspect zero gaps from repeated/rounded values, uneven recording resolution, tiny samples, and dependence. The test responds to spacing structure including multimodal alternatives but does not estimate the number or position of modes. A rejection should lead to distributional visualization rather than a claim of a specific directional effect.
How to use and calibrate
Use Rao-spacing critical values or simulate n uniform angles, recomputing circular gaps.
Example application
Detect multimodal or irregular departures from uniformity.
Interpretation and pitfalls
Watch out
This tests distribution of spacings, not equality of mean directions across groups.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
Angles are in radians on a full circle. The V test specifies direction zero in advance; ordinary Rayleigh does not. Some circular routines return critical-value ranges rather than a continuously resolved p-value.
Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: circular
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
set.seed(2026)
a<-circular::circular(runif(40,0,2*pi),units="radians")
print(circular::rao.spacing.test(a))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Validated — Executed successfully in the validation environment · needs circular
set.seed(2026)
a<-circular::circular(runif(40,0,2*pi),units="radians")
print(circular::rao.spacing.test(a))
Output
Rao's Spacing Test of Uniformity Test Statistic = 138.1238 P-value > 0.10
Sources
- circular — circular · rao.spacing.testAuthor documentation/source reviewed: circular 0.5-2.search.r-project.org
- rao.spacing.testsearch.r-project.org
- circularsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Executed end to end through Rscript · R: Executed successfully in the validation environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 262, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT262.