ADescribe · Guide test 258
Rayleigh test
Tests circular uniformity, with greatest sensitivity to concentration around a single direction.
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 = Rayleigh.
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 · Rayleigh test
Large spreads approach a uniform circle.
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how 2Z varies across samples when H₀ is true (χ²₂ limit drawn; p from the Mardia–Jupp expansion).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .022).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- mean resultant length: 0 for spread, 1 for identical directions
- Rayleigh's statistic; 2Z is approximately χ² with 2 df, the curve drawn
- Mardia–Jupp small-sample expansion, as CodeSplash computes it
The verdict
2Z(2) = 7.52, p = .022, R̄ = 0.35
p ≤ α = .050: reject H₀
Effect size: mean resultant length R̄ = 0.354
Detects one preferred direction. It misses bimodal (axial) data whose resultant cancels; double the angles first for axial data.
- Statistic
- 7.519
- p-value
- 0.0220
Rayleigh test on Directions (°): n = 30: 2Z(2) = 7.52, p = .022, R̄ = 0.35. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: uniform direction on the circle; H1: typically unimodal concentration.
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
2Z is asymptotically χ²2; finite sample Rayleigh corrections depend on n.
Structure of the method
Map each angle to a unit vector, sum cosine/sine components, compute resultant length, and compare its squared scaled magnitude with the circular-uniform reference. This detects the first trigonometric moment; it is not a universal detector of every departure from circular uniformity.
Estimated and nuisance parameters
Estimate mean resultant length and optionally mean direction as descriptive summaries. Under uniformity, direction is undefined, so reporting an apparently precise sample direction after a nonrejection can be misleading. The test itself does not fit a von Mises model or concentration parameter, although such modeling can follow separately.
Settings and design choices
Choose angular units, zero direction, rotation convention, directional versus axial treatment, and finite-sample versus simulated calibration. Axial observations often require angle doubling with corresponding interpretation. Rounding creates ties/discrete support and may require a null respecting the recording resolution instead of continuous uniform angles.
Fitting and adaptation
Adapt by transforming the original measurements into a correctly defined circular domain and retaining the sampling design. For repeated directions from the same subject, use an appropriate dependence-aware model/resampling scheme; treating all observations as independent artificially increases effective sample size. There are no neural hyperparameters to optimize.
Sensitivity and robustness
Inspect antipodal/multimodal patterns, outliers near wrap boundaries, instrument heaping, small samples, and subject clustering. Opposite modes can cancel the resultant and produce nonrejection despite strong nonuniformity. Report a circular plot and concentration/effect summary in addition to the p value.
How to use and calibrate
Use the Rayleigh upper tail or uniform-angle simulation.
Example application
Test whether bearings show a preferred direction.
Interpretation and pitfalls
Watch out
Symmetric multimodal departures can cancel the first resultant and be missed.
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::rayleigh.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::rayleigh.test(a))
Output
Rayleigh Test of Uniformity
General Unimodal Alternative
Test Statistic: 0.1794
P-value: 0.2775Sources
- circular — circular · rayleigh.testAuthor documentation/source reviewed: circular 0.5-2.search.r-project.org
- rayleigh.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 258, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT258.