Skip to content

ADirections & cycles · circular.uniformity

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?

One-sample tests of uniformity on the circle: Rayleigh (one preferred direction), the V test (clustering around a stated direction), Kuiper and Watson U² (any departure) and Rao's spacing test (uneven gaps, several clusters). All five are reported; the one you choose is the headline.

Verified in Python and R Python and R agree to 10 decimals Seeded Also called Rayleigh test, Rayleigh Z, V test…

A real result

Example “Rayleigh turtles”, recorded in both engines. In the app, “Try this example” loads it into Analyze.

Test of circular uniformityRecorded · Python and R agreeRecorded 2026-11-17 · 21 values compared
R

Rayleigh: Z = 13.16, p < .001, n = 76

Rayleigh Z
13.162
p
< .001
Mean resultant length R̄
0.4162

Plots

Rose diagram of headingWhich directions or times of day are most common?
View data
heading
203.20
97.100
38.500
348.40
157.70
86.400
81.800
140.20
60.100
60.800
48.400
93
143
75.300
59.700
139.10
51.300
104.20
59.900
64.300
70.300
71.500
60.100
28
22.500
118.70
77.900
116.30
349.70
124.70
23.200
33.700
80.700
76.300
75
70.400
57.300
323.40
46.900
21.900
46.400
28.300
69.100
176.50
53.100
96.500
113
103.80
125.10
109.30
55
44.300
65.200
66
178.80
45.400
68.800
80
115.10
87.300

First 60 of 76 rows.

heading against a uniform circleHow far are the angles from being spread evenly round the circle?
View data
heading
203.20
97.100
38.500
348.40
157.70
86.400
81.800
140.20
60.100
60.800
48.400
93
143
75.300
59.700
139.10
51.300
104.20
59.900
64.300
70.300
71.500
60.100
28
22.500
118.70
77.900
116.30
349.70
124.70
23.200
33.700
80.700
76.300
75
70.400
57.300
323.40
46.900
21.900
46.400
28.300
69.100
176.50
53.100
96.500
113
103.80
125.10
109.30
55
44.300
65.200
66
178.80
45.400
68.800
80
115.10
87.300

First 60 of 76 rows.

Assumptions

  • Independent angles — Repeated readings of the same animal, site or person break independence; summarize per unit first.

Tests of uniformity

TestDetectsStatisticValuep
Rayleighone preferred directionZ13.1621.131e-6
Kuiperany departureV*3.3042.812e-8
Watson U²any departureU²*0.86507.684e-8
Rao spacinguneven gapsU175.800.0001
  • p-values: published approximations (Rao spacing by simulation); simulations use 9999 uniform samples, seed 42. Kuiper V* and Watson U²* are Stephens' (1970) modified statistics.
Python

Rayleigh: Z = 13.16, p < .001, n = 76

Rayleigh Z
13.162
p
< .001
Mean resultant length R̄
0.4162

To keep this page light, the plots are shown once, under the R tab.

Assumptions

  • Independent angles — Repeated readings of the same animal, site or person break independence; summarize per unit first.

Tests of uniformity

TestDetectsStatisticValuep
Rayleighone preferred directionZ13.1621.131e-6
Kuiperany departureV*3.3042.812e-8
Watson U²any departureU²*0.86507.684e-8
Rao spacinguneven gapsU175.800.0001
  • p-values: published approximations (Rao spacing by simulation); simulations use 9999 uniform samples, seed 42. Kuiper V* and Watson U²* are Stephens' (1970) modified statistics.

Do it in CodeSplash Run it on your own data, in Python or R, with the code to prove it.

Worked examples in the app

  • Rayleigh turtlesci_turtles · angle: heading
  • Rayleigh scatteredci_turtles · angle: scattered
  • V test home 90ci_pigeons · angle: bearing
  • Kuiper hoursci_hours · angle: hour
  • Watson monte carloci_turtles · angle: scattered
  • Rao windci_wind · angle: direction
  • V axial monte carloci_turtles · angle: heading
  • Rayleigh weekday timestampci_hours · angle: stamp

In the guides

Tests from the statistics guide this method runs

What you need

Direction or timenumeric / temporal · 1 column
Angles, clock times, weekdays, months or timestamps.

Choices you make

hypothesis

Testdefault rayleigh

Rayleigh detects one preferred direction; V tests a direction you state; Kuiper, Watson and Rao also catch multiple modes.

  • Rayleigh(default) — Most powerful when the angles cluster around a single direction (von Mises alternative).
  • V test (stated direction) — Rayleigh with a direction stated in advance (e.g. home at 90°); one-sided.
  • Kuiper — Kolmogorov–Smirnov for the circle: detects any shape of non-uniformity.
  • Watson U² — Cramér–von Mises for the circle; often more powerful than Kuiper.
  • Rao spacing — Compares the gaps between neighboring angles with equal spacing; good for several clusters.
Stated direction (in the data's units)default 0

The direction expected in advance — home, the coast, noon. Decide it before looking at the data.

options

Angles are indefault degrees

How the column measures direction. Timestamps are placed in their daily, weekly or yearly cycle (UTC).

  • Degrees (0–360)(default) — Compass bearings, wind directions, orientations.
  • Radians (0–2π) — Reads values as radians from 0 to 2π; pick it for angles from math libraries.
  • Hours of the day (0–24) — Clock times as decimal hours; 23:30 and 00:30 are an hour apart.
  • Day of the week (1 = Monday … 7) — Reads values as weekdays, 1 = Monday to 7; pick it for weekly cycles.
  • Month (1–12) — December and January are neighbors.
  • Day of the year (1–366) — Reads values as day of the year, 1 to 366; pick it for seasonal cycles.
  • Another cycle (set the period) — Any repeating scale: phase of a 28-day cycle, tide hours …
  • Time of day — Position within the day (UTC).
  • Day and time of the week — Monday 00:00 is the start of the cycle (UTC).
  • Time of year — Fraction of the calendar year (leap years have 366 days).
Value of one full turndefault 28

The scale value that brings you back to the start (e.g. 28 for a 28-day cycle).

Axial data (0° and 180° are the same)default off

Orientations without a head or tail: angles are doubled before testing.

statistics

p-valuesdefault approximate

How the p-value is computed: a large-sample formula, or by permutation or simulation (slower, fewer assumptions).

  • Published approximations(default) — Rayleigh and V expansions, Stephens' modified Kuiper and Watson statistics; Rao by simulation.
  • Monte Carlo — Every p from the same simulated uniform samples — exact up to simulation error; best below about 20 angles.
Simulated samplesdefault 9999

Uniform samples for Monte Carlo p-values (and always for Rao's spacing test).

Checks and remedies

CodeSplash checks each testable assumption on every run and shows the result on the card; premises the data can’t test are marked. If a check fails, these are the ways forward.

  • Independent angles

    One angle per animal, site or person; repeated readings inflate the evidence.

What it reports

  • Tests: The angles are not uniformly distributed
n
How many independent units the analysis used; it sets precision and power.
test
The exact variant that ran (for example Welch vs classic F), shown so the result can be reported and reproduced.
statistic
One test of "every component null holds" from several independent tests' p-values.
p
How surprising your data would be if the null hypothesis were true, as a probability.
rbar
How tightly angles cluster, from 0 (spread evenly or canceling out) to 1 (all identical).
mean_direction
The direction of the average of the angles as unit vectors, atan2(Σ sin θ, Σ cos θ).
rayleigh_z
Tests whether angles cluster around one direction rather than spreading evenly; Z = nR̄².
rayleigh_p
Tests whether angles cluster around one direction rather than spreading evenly; Z = nR̄².
kuiper_v
The circular Kolmogorov–Smirnov test (largest gaps above and below the uniform), sensitive to any departure.
kuiper_vstar
The circular Kolmogorov–Smirnov test (largest gaps above and below the uniform), sensitive to any departure.
kuiper_p
The circular Kolmogorov–Smirnov test (largest gaps above and below the uniform), sensitive to any departure.
watson_u2
The circular Cramér–von Mises statistic; detects any departure from uniformity (one sample) or any difference between two samples.
watson_u2star
The circular Cramér–von Mises statistic; detects any departure from uniformity (one sample) or any difference between two samples.
watson_p
The circular Cramér–von Mises statistic; detects any departure from uniformity (one sample) or any difference between two samples.
rao_u
Compares the gaps between neighboring angles with equal spacing (360°/n); good at detecting several clusters.
rao_p
Compares the gaps between neighboring angles with equal spacing (360°/n); good at detecting several clusters.
n_sim
How many independent units the analysis used; it sets precision and power.
v_stat
Rayleigh's test against a direction stated in advance (home, noon); more powerful when that direction is right.
v_u
Rayleigh's test against a direction stated in advance (home, noon); more powerful when that direction is right.
v_p
Rayleigh's test against a direction stated in advance (home, noon); more powerful when that direction is right.
mu0
Rayleigh's test against a direction stated in advance (home, noon); more powerful when that direction is right.

Python and R

Python and R agree to 10 decimals (relative tolerance 1e-10). Python uses pandas, numpy, scipy, codesplash; R uses stats, nanoparquet, codesplashr.

Default traps between the two languages

  • Kuiper and Watson report Stephens' (1970) modified V* and U²*, as R's circular package prints; the p-values come from the asymptotic series rather than circular's critical-value table, so they are numbers rather than ranges.
Python

The exact script CodeSplash ran for example “Rayleigh turtles” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0

# Tests of circular uniformity (Rayleigh, V, Kuiper, Watson, Rao)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method circular.uniformity 1.0.1 · spec 9958f11ee09fbf85
# Dataset: ci_turtles (version 1)
# Runs on its own: outside the app, cs.publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
import numpy as np
import pandas as pd

import codesplash as cs
from codesplash.stats import circular

# %% Data
df = pd.read_parquet("tests/parity/fixtures/ci_turtles.parquet", columns=["heading"])
n_input = len(df)
df = df.dropna(subset=["heading"])  # listwise deletion over the analysis columns
n_dropped = n_input - len(df)
warnings = []
if n_dropped:
    warnings.append(cs.cs_warning("CS_W_ROWS_DROPPED", dropped=n_dropped, total=n_input))
if n_input and not len(df):
    cs.cs_error("CS_E_NO_ROWS")
cs.check_finite_columns(df, ["heading"])  # infinite values stop the run (registry/errors.yaml)

# %% Angles
# Angles become radians in [0, 2π): numeric values in the chosen unit, or a timestamp's position in its
# daily / weekly / yearly cycle (UTC). Axial data (0° ≡ 180°) are doubled before testing.
units = "degrees"
period = None
disp_units = {"time_of_day": "hours", "day_of_week": "weekday", "day_of_year": "doy"}.get(units, units)
axial = False
a_name = "heading"
theta = circular.angles(df[a_name] if units in circular.CYCLES else df[a_name].to_numpy(dtype=float), units, period)
work = circular.wrap(2.0 * theta) if axial else theta
turn = 2.0 * np.pi * (0.5 if axial else 1.0)
unit_scale = circular.period_of(disp_units, period)[0] / (2.0 * np.pi)  # radians → display units


def show(rad):
    """A direction in the user's units (axial: halved back to the axis)."""
    return float(circular.from_radians(np.mod(rad, turn), disp_units, period))


def lab(rad):
    return circular.label(np.mod(rad, turn), units, period)


chart_angles = circular.from_radians(theta, disp_units, period)  # what the charts draw
chart_controls = {"units": disp_units if disp_units != "custom" else "radians", "orientation": "compass" if disp_units in ("degrees", "hours") else "math"}
if disp_units == "custom":
    chart_angles = theta

# %% Tests
test = "rayleigh"
calibration = "approximate"
seed = 42  # shared Wichmann–Hill stream: R simulates the same uniform samples
mu0_value, mu0, mu0_work = None, None, None
r = circular.uniformity(work, mu0=mu0_work, calibration=calibration, n_sim=int(9999), seed=seed)
n = r["n"]
d = circular.describe(theta, axial=axial)

NAMES = {"rayleigh": "Rayleigh", "v": "V", "kuiper": "Kuiper", "watson": "Watson U²", "rao": "Rao spacing"}
STAT = {"rayleigh": ("Z", r["rayleigh_z"], r["rayleigh_p"]), "kuiper": ("V*", r["kuiper_vstar"], r["kuiper_p"]),
        "watson": ("U²*", r["watson_u2star"], r["watson_p"]), "rao": ("U", r["rao_u"], r["rao_p"])}
if mu0 is not None:
    STAT["v"] = ("u", r["v_u"], r["v_p"])
symbol, statistic, p = STAT[test]

# %% Assumptions
assumptions = [{"key": "independence", "label": "Independent angles", "status": "info",
                "detail": "Repeated readings of the same animal, site or person break independence; summarize per unit first."}]
if n < 8:
    warnings.append("Fewer than 8 angles; tests of uniformity have little power.")

# %% Result
how = {"approximate": "published approximations (Rao spacing by simulation)", "monte_carlo": "Monte Carlo"}[calibration]
rows = [{"test": NAMES[k], "alternative": alt, "statistic": STAT[k][1], "symbol": STAT[k][0], "p": STAT[k][2]}
        for k, alt in [("rayleigh", "one preferred direction"), ("v", "clustered around the stated direction"), ("kuiper", "any departure"),
                       ("watson", "any departure"), ("rao", "uneven gaps")] if k in STAT]
values = {"n": n, "test": test, "statistic": statistic, "p": p, "rbar": d["rbar"], "mean_direction": show(d["mean"]),
          "rayleigh_z": r["rayleigh_z"], "rayleigh_p": r["rayleigh_p"], "kuiper_v": r["kuiper_v"], "kuiper_vstar": r["kuiper_vstar"],
          "kuiper_p": r["kuiper_p"], "watson_u2": r["watson_u2"], "watson_u2star": r["watson_u2star"], "watson_p": r["watson_p"],
          "rao_u": r["rao_u"], "rao_p": r["rao_p"], "n_sim": r["n_sim"],
          "v_stat": r.get("v_stat"), "v_u": r.get("v_u"), "v_p": r.get("v_p"), "mu0": mu0_value}
if test == "v":
    verdict = (f"The angles cluster around the stated direction {circular.label(mu0, units, period)}" if p < 0.05
               else f"No evidence that the angles cluster around {circular.label(mu0, units, period)}")
else:
    verdict = "The angles are not uniformly spread" if p < 0.05 else "The data are compatible with angles spread evenly round the circle"
summary = (f"{NAMES[test]} test of uniformity for {a_name} (n = {n}): {symbol} = {statistic:.3f}, {cs.fmt_p(p)}. {verdict}"
           f"; mean direction {lab(d['mean'])}, R̄ = {d['rbar']:.3f}.")
chart_roles = {"angle": cs.col(a_name, np.asarray(chart_angles)[:5000], "numeric")}
cs.publish({
    "method": "circular.uniformity",
    "methodVersion": "1.0.1",
    "title": "Test of circular uniformity",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": n,
    "summary": summary,
    "apa": f"{NAMES[test]}: {symbol} = {cs.fmt_num(statistic)}, {cs.fmt_p(p)}, n = {n}",
    "statistics": [{"key": "statistic", "label": f"{NAMES[test]} {symbol}", "value": statistic},
                   {"key": "p", "label": "p", "value": p, "format": "p"},
                   {"key": "rbar", "label": "Mean resultant length R̄", "value": d["rbar"]}],
    "tables": [{"key": "tests", "title": "Tests of uniformity",
                "columns": [{"key": "test", "label": "Test", "type": "string"}, {"key": "alternative", "label": "Detects", "type": "string"},
                            {"key": "symbol", "label": "Statistic", "type": "string"}, {"key": "statistic", "label": "Value", "type": "number"},
                            {"key": "p", "label": "p", "type": "p"}],
                "rows": rows}],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [f"p-values: {how}; simulations use {r['n_sim']} uniform samples, seed {seed}. Kuiper V* and Watson U²* are Stephens' (1970) modified statistics."],
    "values": values,
    "charts": [cs.chart("rose", "rose-diagram", f"Rose diagram of {a_name}", chart_roles, chart_controls),
               cs.chart("ecdf", "circular-ecdf", f"{a_name} against a uniform circle", chart_roles, chart_controls)],
})
R

The exact script CodeSplash ran for example “Rayleigh turtles” · R version 4.5.1 (2025-06-13)

# Tests of circular uniformity (Rayleigh, V, Kuiper, Watson, Rao)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method circular.uniformity 1.0.1 · spec 9958f11ee09fbf85
# Dataset: ci_turtles (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.

# %% Setup
library(codesplashr)

# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/ci_turtles.parquet", col_select = c("heading")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("heading")]), , drop = FALSE]  # listwise deletion
df[] <- lapply(df, function(x) if (is.factor(x)) droplevels(x) else x)
n_dropped <- n_input - nrow(df)
warnings <- list()
if (n_dropped > 0) {
  warnings <- c(warnings, cs_warning("CS_W_ROWS_DROPPED", dropped = n_dropped, total = n_input))
}
if (n_input > 0 && nrow(df) == 0) cs_error("CS_E_NO_ROWS")
cs_check_finite_columns(df, c("heading"))  # infinite values stop the run (registry/errors.yaml)

# %% Angles
# Angles become radians in [0, 2*pi): numeric values in the chosen unit, or a timestamp's position in
# its daily / weekly / yearly cycle (UTC). Axial data (0° = 180°) are doubled before testing.
units <- "degrees"
period <- NULL
disp_units <- switch(units, time_of_day = "hours", day_of_week = "weekday", day_of_year = "doy", units)
axial <- FALSE
a_name <- "heading"
theta <- cs_circ_angles(df[[a_name]], units, period)
work <- if (axial) cs_circ_wrap(2 * theta) else theta
turn <- 2 * pi * (if (axial) 0.5 else 1)
unit_scale <- (if (disp_units == "custom") period else switch(disp_units, degrees = 360, radians = 2 * pi, hours = 24, weekday = 7, month = 12, doy = 365.25)) / (2 * pi)

show <- function(rad) cs_circ_from_radians(rad %% turn, disp_units, period)
lab <- function(rad) cs_circ_label(rad %% turn, units, period)

chart_angles <- cs_circ_from_radians(theta, disp_units, period)
chart_controls <- list(units = if (disp_units != "custom") disp_units else "radians",
                       orientation = if (disp_units %in% c("degrees", "hours")) "compass" else "math")
if (disp_units == "custom") chart_angles <- theta

# %% Tests
test <- "rayleigh"
calibration <- "approximate"
seed <- 42  # shared Wichmann-Hill stream: Python simulates the same uniform samples
mu0_value <- NULL
mu0 <- NULL
mu0_work <- NULL
r <- cs_circ_uniformity(work, mu0 = mu0_work, calibration = calibration, n_sim = 9999, seed = seed)
n <- r$n
d <- cs_circ_describe(theta, axial = axial)

NAMES <- c(rayleigh = "Rayleigh", v = "V", kuiper = "Kuiper", watson = "Watson U²", rao = "Rao spacing")
STAT <- list(rayleigh = list("Z", r$rayleigh_z, r$rayleigh_p), kuiper = list("V*", r$kuiper_vstar, r$kuiper_p),
             watson = list("U²*", r$watson_u2star, r$watson_p), rao = list("U", r$rao_u, r$rao_p))
if (!is.null(mu0)) STAT$v <- list("u", r$v_u, r$v_p)
symbol <- STAT[[test]][[1]]
statistic <- STAT[[test]][[2]]
p <- STAT[[test]][[3]]

# %% Assumptions
assumptions <- list(list(key = "independence", label = "Independent angles", status = "info",
                         detail = "Repeated readings of the same animal, site or person break independence; summarize per unit first."))
if (n < 8) warnings <- c(warnings, "Fewer than 8 angles; tests of uniformity have little power.")

# %% Result
how <- c(approximate = "published approximations (Rao spacing by simulation)", monte_carlo = "Monte Carlo")[[calibration]]
alts <- list(c("rayleigh", "one preferred direction"), c("v", "clustered around the stated direction"), c("kuiper", "any departure"),
             c("watson", "any departure"), c("rao", "uneven gaps"))
rows <- list()
for (a in alts) {
  if (!is.null(STAT[[a[1]]])) {
    rows[[length(rows) + 1]] <- list(test = NAMES[[a[1]]], alternative = a[2], statistic = STAT[[a[1]]][[2]], symbol = STAT[[a[1]]][[1]], p = STAT[[a[1]]][[3]])
  }
}
values <- list(n = n, test = test, statistic = statistic, p = p, rbar = d$rbar, mean_direction = show(d$mean),
               rayleigh_z = r$rayleigh_z, rayleigh_p = r$rayleigh_p, kuiper_v = r$kuiper_v, kuiper_vstar = r$kuiper_vstar,
               kuiper_p = r$kuiper_p, watson_u2 = r$watson_u2, watson_u2star = r$watson_u2star, watson_p = r$watson_p,
               rao_u = r$rao_u, rao_p = r$rao_p, n_sim = r$n_sim,
               v_stat = r$v_stat, v_u = r$v_u, v_p = r$v_p, mu0 = mu0_value)
verdict <- if (test == "v") {
  if (p < 0.05) paste("The angles cluster around the stated direction", cs_circ_label(mu0, units, period))
  else paste("No evidence that the angles cluster around", cs_circ_label(mu0, units, period))
} else if (p < 0.05) "The angles are not uniformly spread" else "The data are compatible with angles spread evenly round the circle"
summary <- sprintf("%s test of uniformity for %s (n = %d): %s = %.3f, %s. %s; mean direction %s, R̄ = %.3f.",
                   NAMES[[test]], a_name, n, symbol, statistic, cs_fmt_p(p), verdict, lab(d$mean), d$rbar)
take <- seq_len(min(nrow(df), 5000))
chart_roles <- list(angle = cs_col(a_name, chart_angles[take], "numeric"))
cs_publish(list(
  method = "circular.uniformity",
  methodVersion = "1.0.1",
  title = "Test of circular uniformity",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = sprintf("%s: %s = %s, %s, n = %d", NAMES[[test]], symbol, cs_fmt_num(statistic), cs_fmt_p(p), n),
  statistics = list(list(key = "statistic", label = paste(NAMES[[test]], symbol), value = statistic),
                    list(key = "p", label = "p", value = p, format = "p"),
                    list(key = "rbar", label = "Mean resultant length R̄", value = d$rbar)),
  tables = list(list(key = "tests", title = "Tests of uniformity",
                     columns = list(list(key = "test", label = "Test", type = "string"), list(key = "alternative", label = "Detects", type = "string"),
                                    list(key = "symbol", label = "Statistic", type = "string"), list(key = "statistic", label = "Value", type = "number"),
                                    list(key = "p", label = "p", type = "p")),
                     rows = rows)),
  assumptions = assumptions,
  warnings = warnings,
  notes = list(sprintf("p-values: %s; simulations use %d uniform samples, seed %d. Kuiper V* and Watson U²* are Stephens' (1970) modified statistics.",
                       how, as.integer(r$n_sim), as.integer(seed))),
  values = values,
  charts = list(cs_chart("rose", "rose-diagram", paste("Rose diagram of", a_name), chart_roles, chart_controls),
                cs_chart("ecdf", "circular-ecdf", paste(a_name, "against a uniform circle"), chart_roles, chart_controls))
))

Sources

  • Mardia, K. V., & Jupp, P. E. (2000). Directional Statistics. Wiley, §6.3.
  • Stephens, M. A. (1970). Use of the Kolmogorov–Smirnov, Cramér–von Mises and related statistics without extensive tables. JRSS B, 32, 115–122.
  • Durand, D., & Greenwood, J. A. (1958). Modifications of the Rayleigh test for uniformity in analysis of two-dimensional orientation data. Journal of Geology, 66, 229–238.
  • Rao, J. S. (1976). Some tests based on arc-lengths for the circle. Sankhyā B, 38, 329–338.
  • Zar, J. H. (2010). Biostatistical Analysis (5th ed.), ch. 27.

From the CodeSplash method registry · circular.uniformity v1.0.1.