Skip to content

ADescribe · Guide test 262

Rao spacing test

Tests circular uniformity using departures of angular spacings from equal spacing.

Runs in CodeSplashPython (calls R) example not runR example validated

Do it in CodeSplash

In the app, set it up in Analyze with this method:

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

30
60
70

Large spreads approach a uniform circle.

0.050

Your data

Drag a point or use ↑/↓ to change it
0°90°180°270°Directions: n = 30, θ̄ = 57°, R̄ = 0.35

Sectors 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

U = 150.02
  1. 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).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .102).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

U=12∑i=1n∣Di−360∘n∣U=\tfrac12\sum_{i=1}^{n}\Big|D_i-\frac{360^\circ}n\Big|

With your numbers

U=150.0∘,360∘/n=12∘U = 150.0^\circ,\quad 360^\circ/n = 12^\circ
DiD_i
the gap from each direction to the next, going round the circle
360∘/n360^\circ/n
the gap if the directions were perfectly even
UU
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 H0.

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

U=12∑i=1n∣Di−2π/n∣U=\tfrac12\sum_{i=1}^{n}|D_i-2\pi/n|

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.

Python · invokes R

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()
R

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

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.