Skip to content

ADirections & cycles · circular.describe

Circular summary (mean direction, R̄, κ)

What is the typical direction or time of day, and how concentrated are the angles around it?

Mean direction with a confidence interval, mean resultant length R̄, circular standard deviation and the von Mises concentration κ — for compass bearings, clock times, weekdays and seasons, where 359° and 1° are neighbors and an ordinary mean is wrong.

Verified in Python and R Python and R agree to 10 decimals Seeded Also called circular mean, mean direction, mean resultant length…

A real result

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

Circular summaryRecorded · Python and R agreeRecorded 2026-11-17 · 17 values compared
R

θ̄ = 84.1°, R̄ = 0.42, κ = 0.92, n = 76

Mean direction
84.101
Mean resultant length R̄
0.4162
Concentration κ (von Mises)
0.9169
Circular SD
75.868

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.

Circular density of headingWhat shape does the distribution of directions have — one peak, two, or none?
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

  • A mean direction exists — Rayleigh Z = 13.16, p < .001: the angles cluster around a direction.
  • One preferred direction — R̄ of doubled angles 0.41.

Directions

GroupnMean directionMean (degrees)R̄Circular SD (degrees)κ
All7684.1°84.1010.416275.8680.9169
  • Angles in degrees; interval: normal approximation. κ is the von Mises maximum-likelihood estimate (bias-corrected 0.89).
Python

θ̄ = 84.1°, R̄ = 0.42, κ = 0.92, n = 76

Mean direction
84.101
Mean resultant length R̄
0.4162
Concentration κ (von Mises)
0.9169
Circular SD
75.868

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

Assumptions

  • A mean direction exists — Rayleigh Z = 13.16, p < .001: the angles cluster around a direction.
  • One preferred direction — R̄ of doubled angles 0.41.

Directions

GroupnMean directionMean (degrees)R̄Circular SD (degrees)κ
All7684.1°84.1010.416275.8680.9169
  • Angles in degrees; interval: normal approximation. κ is the von Mises maximum-likelihood estimate (bias-corrected 0.89).

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

  • Turtlesci_turtles · angle: heading
  • Turtles axialci_turtles · angle: heading
  • Hours by channelci_hours · angle: hour · group: channel
  • Timestamp time of dayci_hours · angle: stamp
  • Timestamp time of yearci_hours · angle: stamp
  • Weekday bootstrapci_hours · angle: weekday
  • Pigeons by group 90ci_pigeons · angle: bearing · group: group
  • Degenerate constantci_turtles · angle: heading

In the guides

Where it sits in the decision guides

  • Continuous: mean, median, SD, IQR · Statistics Guide · A — Describe data

What you need

Direction or timenumeric / temporal · 1 column
Angles, clock times, weekdays, months or timestamps.
Split bycategorical / boolean · 0–1 column · 1–12 levels
Optional — summarize each group's direction separately.

Choices you make

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 (fault lines, fiber directions): angles are doubled before the analysis and halved after.

statistics

Interval for the mean directiondefault normal

Interval for the mean direction: a normal approximation, or a bootstrap (better for small or skewed samples).

  • Normal approximation(default) — θ̄ ± arcsin(z·σ̂) with the circular standard error (Fisher 1993); fine from about 25 angles.
  • Bootstrap percentile — Resamples the angles; better for small or skewed samples.
Bootstrap samplesdefault 2000

Number of bootstrap resamples. More gives steadier intervals but takes longer; use 1,000 or more for reporting.

Confidence leveldefault 0.95

How sure the intervals should be: 0.95 gives 95% confidence intervals. Higher confidence means wider intervals.

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.

  • A mean direction exists

    Rayleigh test: with angles spread all round the circle the mean direction is meaningless.

    • If violated → Test for uniformity — Kuiper and Watson tests detect any departure from uniformity, including several clusters.
  • One preferred direction

    Two opposite clusters cancel out; treat such data as axial.

    • If violated → Treat as axial — Doubling the angles merges two opposite clusters into one, so the axis has a well-defined mean. Changes the question: Describes an axis (a direction modulo 180°) instead of a direction.

What it reports

n
How many independent units the analysis used; it sets precision and power.
mean_direction
The direction of the average of the angles as unit vectors, atan2(Σ sin θ, Σ cos θ).
mean_direction_rad
The direction of the average of the angles as unit vectors, atan2(Σ sin θ, Σ cos θ).
mean_label
The direction of the average of the angles as unit vectors, atan2(Σ sin θ, Σ cos θ).
ci_low
A range of effect values compatible with your data at the chosen confidence level.
ci_high
A range of effect values compatible with your data at the chosen confidence level.
rbar
How tightly angles cluster, from 0 (spread evenly or canceling out) to 1 (all identical).
circ_variance
Spread of angles, √(−2 ln R̄), reported in the data's units (degrees, hours).
circ_sd
Spread of angles, √(−2 ln R̄), reported in the data's units (degrees, hours).
ang_dev
Spread of angles, √(−2 ln R̄), reported in the data's units (degrees, hours).
kappa
The von Mises distribution's concentration; 0 is uniform, about 2 is moderately clustered, above 10 very tight.
kappa_corrected
The von Mises distribution's concentration; 0 is uniform, about 2 is moderately clustered, above 10 very tight.
se
The typical size of the error in an estimate, the standard deviation of its sampling distribution.
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̄².
rbar_doubled
How tightly angles cluster, from 0 (spread evenly or canceling out) to 1 (all identical).
n_groups
How many independent units the analysis used; it sets precision and power.

Per group, level or term: mean_direction[<group>], rbar[<group>], kappa[<group>], n[<group>]

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

  • κ is the exact maximum-likelihood solution of A₁(κ) = R̄ (Newton on scaled Bessel functions); R's circular::A1inv uses Best & Fisher's closed-form approximation, so its κ differs in the third digit.
Python

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

# Circular summary (mean direction, R̄, κ)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method circular.describe 1.0.1 · spec 3b1a0ed1fe460219
# 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

# %% Summaries
conf = 0.95
ci_method = "normal"
seed = 42  # shared Wichmann–Hill stream: R draws the same bootstrap samples
d = circular.describe(theta, conf=conf, axial=axial, ci_method=ci_method, n_boot=int(2000), seed=seed)
ray = circular.rayleigh(work)
n = d["n"]
double = circular.resultant(circular.wrap(2.0 * theta))[2]  # R̄ of doubled angles: high when the data are axial/bipolar

g_name = None
groups = []
if g_name is not None:
    for lv in df[g_name].cat.categories:
        sel = (df[g_name] == lv).to_numpy()
        if sel.sum() == 0:
            continue
        dg = circular.describe(theta[sel], conf=conf, axial=axial, ci_method="normal")
        groups.append({"group": str(lv), "n": int(sel.sum()), "mean": show(dg["mean"]), "label": lab(dg["mean"]), "rbar": dg["rbar"],
                       "circ_sd": dg["circ_sd"] * unit_scale, "kappa": dg["kappa"]})

# %% Assumptions
assumptions = []
if ray["p"] >= 0.05:
    assumptions.append({"key": "direction", "label": "A mean direction exists", "status": "warn", "statistic": ray["z"], "p": ray["p"],
                        "detail": f"Rayleigh {cs.fmt_p(ray['p'])}: the angles may be spread uniformly, so the mean direction is not well defined."})
else:
    assumptions.append({"key": "direction", "label": "A mean direction exists", "status": "pass", "statistic": ray["z"], "p": ray["p"],
                        "detail": f"Rayleigh Z = {ray['z']:.2f}, {cs.fmt_p(ray['p'])}: the angles cluster around a direction."})
if not axial and double > 0.5 and d["rbar"] < 0.5 * double:
    assumptions.append({"key": "unimodal", "label": "One preferred direction", "status": "warn",
                        "detail": f"The doubled angles are far more concentrated (R̄ = {double:.2f} vs {d['rbar']:.2f}): two opposite directions. Treat the data as axial."})
else:
    assumptions.append({"key": "unimodal", "label": "One preferred direction", "status": "pass", "detail": f"R̄ of doubled angles {double:.2f}."})
if n < 10:
    warnings.append("Fewer than 10 angles; the interval and κ are unstable.")
if not d["ci_ok"]:
    warnings.append("The angles are too dispersed for a normal-approximation interval; use the bootstrap interval or report R̄ only.")

# %% Result
rows = [{"group": "All", "n": n, "mean": show(d["mean"]), "label": lab(d["mean"]), "rbar": d["rbar"], "circ_sd": d["circ_sd"] * unit_scale, "kappa": d["kappa"]}] + groups
values = {
    "n": n, "mean_direction": show(d["mean"]), "mean_direction_rad": d["mean"], "mean_label": lab(d["mean"]),
    "ci_low": show(d["ci_low"]) if d["ci_ok"] else None, "ci_high": show(d["ci_high"]) if d["ci_ok"] else None,
    "rbar": d["rbar"], "circ_variance": d["variance"], "circ_sd": d["circ_sd"] * unit_scale, "ang_dev": d["ang_dev"] * unit_scale,
    "kappa": d["kappa"], "kappa_corrected": d["kappa_corrected"], "se": d["se"] * unit_scale,
    "rayleigh_z": ray["z"], "rayleigh_p": ray["p"], "rbar_doubled": double, "n_groups": len(groups),
}
for g in groups:
    values[f"mean_direction[{g['group']}]"] = g["mean"]
    values[f"rbar[{g['group']}]"] = g["rbar"]
    values[f"kappa[{g['group']}]"] = g["kappa"]
    values[f"n[{g['group']}]"] = g["n"]
ci_txt = (f"{conf:.0%} CI {lab(d['ci_low'])} to {lab(d['ci_high'])}" if d["ci_ok"] else "no interval (too dispersed)")
how = "bootstrap percentile, seed " + str(seed) if ci_method == "bootstrap" else "normal approximation"
summary = (f"Mean direction of {a_name}: {lab(d['mean'])} ({ci_txt}); mean resultant length R̄ = {d['rbar']:.3f}, "
           f"concentration κ = {d['kappa']:.2f}. " + ("The angles cluster around this direction." if ray["p"] < 0.05 else "The angles show no clear preferred direction, so treat the mean with caution."))
chart_roles = {"angle": cs.col(a_name, np.asarray(chart_angles)[:5000], "numeric")}
if g_name is not None:
    chart_roles["group"] = cs.col(g_name, df[g_name].astype(str).to_numpy()[:5000], levels=[str(x) for x in df[g_name].cat.categories])
cs.publish({
    "method": "circular.describe",
    "methodVersion": "1.0.1",
    "title": "Circular summary",
    "engine": cs.engine_info("pandas", "numpy", "scipy"),
    "n": n,
    "summary": summary,
    "apa": f"θ̄ = {lab(d['mean'])}, R̄ = {cs.fmt_num(d['rbar'])}, κ = {cs.fmt_num(d['kappa'])}, n = {n}",
    "statistics": [
        {"key": "mean_direction", "label": "Mean direction", "value": show(d["mean"])},
        {"key": "rbar", "label": "Mean resultant length R̄", "value": d["rbar"]},
        {"key": "kappa", "label": "Concentration κ (von Mises)", "value": d["kappa"]},
        {"key": "circ_sd", "label": "Circular SD", "value": d["circ_sd"] * unit_scale},
    ],
    "tables": [{
        "key": "summary", "title": "Directions",
        "columns": [{"key": "group", "label": "Group", "type": "string"}, {"key": "n", "label": "n", "type": "integer"},
                    {"key": "label", "label": "Mean direction", "type": "string"}, {"key": "mean", "label": f"Mean ({disp_units})", "type": "number"},
                    {"key": "rbar", "label": "R̄", "type": "number"}, {"key": "circ_sd", "label": f"Circular SD ({disp_units})", "type": "number"},
                    {"key": "kappa", "label": "κ", "type": "number"}],
        "rows": rows,
    }],
    "assumptions": assumptions,
    "warnings": warnings,
    "notes": [f"Angles in {units}{' (axial: doubled, then halved)' if axial else ''}; interval: {how}. κ is the von Mises maximum-likelihood estimate (bias-corrected {d['kappa_corrected']:.2f})."],
    "values": values,
    "charts": [cs.chart("rose", "rose-diagram", f"Rose diagram of {a_name}", chart_roles, chart_controls),
               cs.chart("density", "circular-density", f"Circular density of {a_name}", chart_roles, {**chart_controls, "fit": True})],
})
R

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

# Circular summary (mean direction, R̄, κ)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method circular.describe 1.0.1 · spec 3b1a0ed1fe460219
# 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

# %% Summaries
conf <- 0.95
ci_method <- "normal"
seed <- 42  # shared Wichmann-Hill stream: Python draws the same bootstrap samples
d <- cs_circ_describe(theta, conf = conf, axial = axial, ci_method = ci_method, n_boot = 2000, seed = seed)
ray <- cs_circ_rayleigh(work)
n <- d$n
double <- cs_circ_resultant(cs_circ_wrap(2 * theta))$rbar  # R̄ of doubled angles: high when the data are axial/bipolar

g_name <- NULL
groups <- list()
if (!is.null(g_name)) {
  for (lv in levels(df[[g_name]])) {
    sel <- df[[g_name]] == lv
    if (sum(sel) == 0) next
    dg <- cs_circ_describe(theta[sel], conf = conf, axial = axial, ci_method = "normal")
    groups[[length(groups) + 1]] <- list(group = lv, n = sum(sel), mean = show(dg$mean), label = lab(dg$mean), rbar = dg$rbar,
                                         circ_sd = dg$circ_sd * unit_scale, kappa = dg$kappa)
  }
}

# %% Assumptions
direction <- if (ray$p >= 0.05) {
  list(key = "direction", label = "A mean direction exists", status = "warn", statistic = ray$z, p = ray$p,
       detail = sprintf("Rayleigh %s: the angles may be spread uniformly, so the mean direction is not well defined.", cs_fmt_p(ray$p)))
} else {
  list(key = "direction", label = "A mean direction exists", status = "pass", statistic = ray$z, p = ray$p,
       detail = sprintf("Rayleigh Z = %.2f, %s: the angles cluster around a direction.", ray$z, cs_fmt_p(ray$p)))
}
unimodal <- if (!axial && double > 0.5 && d$rbar < 0.5 * double) {
  list(key = "unimodal", label = "One preferred direction", status = "warn",
       detail = sprintf("The doubled angles are far more concentrated (R̄ = %.2f vs %.2f): two opposite directions. Treat the data as axial.", double, d$rbar))
} else {
  list(key = "unimodal", label = "One preferred direction", status = "pass", detail = sprintf("R̄ of doubled angles %.2f.", double))
}
assumptions <- list(direction, unimodal)
if (n < 10) warnings <- c(warnings, "Fewer than 10 angles; the interval and κ are unstable.")
if (!d$ci_ok) warnings <- c(warnings, "The angles are too dispersed for a normal-approximation interval; use the bootstrap interval or report R̄ only.")

# %% Result
rows <- c(list(list(group = "All", n = n, mean = show(d$mean), label = lab(d$mean), rbar = d$rbar, circ_sd = d$circ_sd * unit_scale, kappa = d$kappa)), groups)
values <- list(
  n = n, mean_direction = show(d$mean), mean_direction_rad = d$mean, mean_label = lab(d$mean),
  ci_low = if (d$ci_ok) show(d$ci_low) else NULL, ci_high = if (d$ci_ok) show(d$ci_high) else NULL,
  rbar = d$rbar, circ_variance = d$variance, circ_sd = d$circ_sd * unit_scale, ang_dev = d$ang_dev * unit_scale,
  kappa = d$kappa, kappa_corrected = d$kappa_corrected, se = d$se * unit_scale,
  rayleigh_z = ray$z, rayleigh_p = ray$p, rbar_doubled = double, n_groups = length(groups)
)
for (g in groups) {
  values[[sprintf("mean_direction[%s]", g$group)]] <- g$mean
  values[[sprintf("rbar[%s]", g$group)]] <- g$rbar
  values[[sprintf("kappa[%s]", g$group)]] <- g$kappa
  values[[sprintf("n[%s]", g$group)]] <- g$n
}
ci_txt <- if (d$ci_ok) sprintf("%.0f%% CI %s to %s", conf * 100, lab(d$ci_low), lab(d$ci_high)) else "no interval (too dispersed)"
how <- if (ci_method == "bootstrap") paste("bootstrap percentile, seed", seed) else "normal approximation"
summary <- paste0(sprintf("Mean direction of %s: %s (%s); mean resultant length R̄ = %.3f, concentration κ = %.2f. ", a_name, lab(d$mean), ci_txt, d$rbar, d$kappa),
                  if (ray$p < 0.05) "The angles cluster around this direction." else "The angles show no clear preferred direction, so treat the mean with caution.")
take <- seq_len(min(nrow(df), 5000))
chart_roles <- list(angle = cs_col(a_name, chart_angles[take], "numeric"))
if (!is.null(g_name)) chart_roles$group <- cs_col(g_name, as.character(df[[g_name]])[take], levels = levels(df[[g_name]]))
cs_publish(list(
  method = "circular.describe",
  methodVersion = "1.0.1",
  title = "Circular summary",
  engine = cs_engine_info("stats", "nanoparquet"),
  n = n,
  summary = summary,
  apa = sprintf("θ̄ = %s, R̄ = %s, κ = %s, n = %d", lab(d$mean), cs_fmt_num(d$rbar), cs_fmt_num(d$kappa), n),
  statistics = list(
    list(key = "mean_direction", label = "Mean direction", value = show(d$mean)),
    list(key = "rbar", label = "Mean resultant length R̄", value = d$rbar),
    list(key = "kappa", label = "Concentration κ (von Mises)", value = d$kappa),
    list(key = "circ_sd", label = "Circular SD", value = d$circ_sd * unit_scale)
  ),
  tables = list(list(
    key = "summary", title = "Directions",
    columns = list(list(key = "group", label = "Group", type = "string"), list(key = "n", label = "n", type = "integer"),
                   list(key = "label", label = "Mean direction", type = "string"), list(key = "mean", label = sprintf("Mean (%s)", disp_units), type = "number"),
                   list(key = "rbar", label = "R̄", type = "number"), list(key = "circ_sd", label = sprintf("Circular SD (%s)", disp_units), type = "number"),
                   list(key = "kappa", label = "κ", type = "number")),
    rows = rows
  )),
  assumptions = assumptions,
  warnings = warnings,
  notes = list(sprintf("Angles in %s%s; interval: %s. κ is the von Mises maximum-likelihood estimate (bias-corrected %.2f).",
                       units, if (axial) " (axial: doubled, then halved)" else "", how, d$kappa_corrected)),
  values = values,
  charts = list(cs_chart("rose", "rose-diagram", paste("Rose diagram of", a_name), chart_roles, chart_controls),
                cs_chart("density", "circular-density", paste("Circular density of", a_name), chart_roles, c(chart_controls, list(fit = TRUE))))
))

Sources

  • Mardia, K. V., & Jupp, P. E. (2000). Directional Statistics. Wiley, ch. 2–5.
  • Fisher, N. I. (1993). Statistical Analysis of Circular Data. Cambridge University Press, §4.4–4.5.
  • Best, D. J., & Fisher, N. I. (1981). The bias of the maximum likelihood estimators of the von Mises–Fisher concentration parameters. Comm. Stat. B, 10, 493–502.

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