Skip to content
svgcircular-ecdf

Circular ECDF vs uniform

How far are the angles from being spread evenly round the circle?

Demo data · seed 20261101 · 600 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read the curve as the cumulative share going round from 0.
  2. A diagonal line means an even spread round the circle.
  3. Read the largest gaps as Kuiper's statistic.
  1. Callout 1: The largest gap from uniform.
  2. Callout 2: The uniform diagonal.

Watch out

  • The starting point is arbitrary; that's why Kuiper's test uses both gaps.

Defaults

Angles are in
Hours of the day
How the column measures direction; the dial is labelled to match.
Also: Degrees · Radians · Weekday (1 = Mon) · Month (1–12) · Day of year

Pinned in the code

  • x = position round the circle from angle 0; y = share of angles at or before it; the dashed diagonal is a uniform circle.
  • Kuiper's V = D⁺ + D⁻ (largest gaps above and below the diagonal) does not depend on where the circle is cut; Stephens' V* = V(√n + 0.155 + 0.24/√n).

Use with care

The curve itself depends on the starting point 0; only D⁺ + D⁻ is rotation invariant.

# Circular ECDF vs uniform — Codesplash Chart Lab (recipe "circular-ecdf")
# controls: units=hours
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("circular-ecdf-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
UNITS, COMPASS = "hours", True  # compass: 0 at the top, clockwise; else 0 at the right, counter-clockwise
PERIOD, ORIGIN = 24, 0  # one full turn, and the value at angle 0
TICK_T = [0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875]
TICK_LABELS = ["00:00", "03:00", "06:00", "09:00", "12:00", "15:00", "18:00", "21:00"]
def to_turn(v):
    return np.mod((np.asarray(v, dtype=float) - ORIGIN) / PERIOD, 1.0)
def kuiper(t):
    u = np.sort(t)
    n = len(u)
    F = np.arange(1, n + 1) / n
    plus, minus = F - u, u - (F - 1 / n)
    ip, im = int(np.argmax(plus)), int(np.argmax(minus))  # first largest gaps, as the app
    return u, F, max(plus[ip], 0), u[ip], max(minus[im], 0), u[im], ip, im
A = "hour"
t = to_turn(df[A].dropna())
u, F, d_plus, at_plus, d_minus, at_minus, ip, im = kuiper(t)
n = len(u)
vstar = (d_plus + d_minus) * (np.sqrt(n) + 0.155 + 0.24 / np.sqrt(n))  # Kuiper's modified V*
fig, ax = plt.subplots(figsize=(7, 5))
ax.plot([0, 1], [0, 1], color=REF, linestyle="--", linewidth=1, label="uniform")
ax.step(np.concatenate([[0], u, [1]]), np.concatenate([[0], F, [1]]), where="post", color=PALETTE[0], linewidth=2, label=A)
ax.plot([at_plus, at_plus], [at_plus, F[ip]], color=PALETTE[3], linewidth=2.5, label=f"Kuiper D+ and D- (V* = {vstar:.2f})")
ax.plot([at_minus, at_minus], [F[im] - 1 / n, at_minus], color=PALETTE[3], linewidth=2.5)
ax.set_xticks(TICK_T, TICK_LABELS)
ax.set_xlim(0, 1)
ax.set_ylim(0, 1)
ax.set_xlabel(A)
ax.set_ylabel("cumulative share")
ax.legend(fontsize=8, loc="upper left")
plt.show()

Needs pandas, numpy, matplotlib · reads circular-ecdf-demo.csv · app theme from the optional codesplash helper