DPredict · Guide test 232
Buishand U test
Tests mean homogeneity using squared cumulative deviations.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Change-point tests (level shifts) — Did the level of the series jump at some point — and if so, when, and by how much?
In Change-point tests (level shifts), choose Test = Buishand U.
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 · Buishand U test
Each error carries φ × the previous one; 1 is a random walk.
Your data
Simulated with a known ρIf H₀ were true
- The reference: how U varies across samples when H₀ is true, U of n = 50 normal values (Monte Carlo null: 1,999 samples simulated under H₀ (seed 20261107)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .021).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- adjusted partial sums
- a Cramér–von Mises type summary of the whole path
- the sample standard deviation, divisor n − 1. The edition-2 reference divides by n (Dₓ), which makes its U larger by n/(n − 1); the p-value is the same either way
The verdict
U = 0.54, p = .021
p ≤ α = .050: reject H₀
More sensitive than the range test to shifts near the ends of the series.
- Statistic
- 0.541
- p-value
- 0.0205
Buishand U test on 50 (x, y) pairs: U = 0.54, p = .021. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0: constant mean throughout the series; H1: a level shift.
Assumptions
Independent normal observations with common variance under the standard null; complete data and no unmodeled trend.
Formula
Parameters and notation
Sk=Σi≤k(xi−x̄),S0=0; Dx²=n⁻¹Σ(xi−x̄)². The range statistic is sometimes reported without √n; tables must match.
Structure of the method
Center and scale the observations, form all cumulative deviations, square them, and aggregate over candidate positions with the Buishand U normalization. This integrated cumulative-discrepancy approach differs from the range statistic’s reliance on two extrema; both require their own matching null calibration.
Estimated and nuisance parameters
Estimate the global null mean and scale and the cumulative deviation path. The algorithm does not fit a separate mean at every split or learn neural parameters. The statistic summarizes evidence for mean instability; an additional location estimator or multiple-break model answers a different question.
Settings and design choices
Choose sample interval, scale convention, simulation count/seed, and the exact U definition used by the software. More simulations reduce Monte Carlo uncertainty but do not increase information in the observed record. Reusing the Buishand range table for U is incorrect even when both methods use the same centered data.
Fitting and adaptation
For simulation calibration, generate iid normal samples under the location-scale-invariant null and repeat centering/scaling and the full sum-of-squares calculation. If fitted preprocessing is part of the workflow, include it in a valid calibration scheme. Adaptation concerns the null model and data design, not neural learning-rate tuning.
Sensitivity and robustness
Check serial dependence, nonnormal tails, smooth trends, multiple breaks, and record-length effects. The integrated score can respond to sustained cumulative departures even when a single abrupt shift is a poor model. The inherited range-normalization sentence is not needed for this U-specific entry; keep its own denominator explicit.
How to use and calibrate
Use Buishand-specific critical values or normal-null Monte Carlo simulation at the observed n.
Example application
Check a measurement record for a mean discontinuity.
Interpretation and pitfalls
Watch out
Serial dependence and gradual trends can mimic shifts. The standard deviation requires squared deviations; some rendered manuals omit that square.
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.
- Rewritten in the review: parameters and notation.
Parameters and notationsearch.r-project.org
The prior range/sqrt(n) sentence was copied from a different Buishand statistic and is irrelevant to this U entry.
Corrected text
S_k=Σ_{i≤k}(x_i−x̄), S_0=0, and D_x²=n⁻¹Σ_i(x_i−x̄)². The displayed U sums squared standardized cumulative deviations over k=1,…,n−1 and divides by n(n+1); use U-specific critical values or simulation.
Python and R
Keep observations in temporal order. Serial correlation and seasonality can invalidate the default independent-error calibration; do not treat the selected change point as known in advance.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: trend
# 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)
x<-seq_len(60)*.02+rnorm(60)
print(trend::bu.test(x))
"""
# 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()
Not run — Syntax checked; runtime not verified in the final environment · needs trend
set.seed(2026)
x<-seq_len(60)*.02+rnorm(60)
print(trend::bu.test(x))
Sources
- trend — trend · bu.testAuthor documentation/source reviewed: trend 1.1.10.search.r-project.org
- bu.testsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final 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 232, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT232.