Skip to content

DPredict · Guide test 233

Standard normal homogeneity test

Tests a mean shift in a standardized series under its normal reference model.

Runs in CodeSplashPython (calls R) example not runR example not run

Do it in CodeSplash

In the app, set it up in Analyze with this method:

In Change-point tests (level shifts), choose Test = Standard normal homogeneity (SNHT).

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 · Standard normal homogeneity test

40
0.000
0.00

Each error carries φ × the previous one; 1 is a random walk.

1.2
0.050

Your data

Simulated with a known ρ

If H₀ were true

T₀ = 7.50
  1. The reference: how T₀ varies across samples when H₀ is true, simulated: 4,999 N(0, 1) series of 40 (Monte Carlo under independent normal errors).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .069).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

T(k)=k zˉ12+(n−k) zˉ22,T0=max⁡1≤k<nT(k),zt=yt−yˉsT(k)=k\,\bar z_1^2+(n-k)\,\bar z_2^2,\qquad T_0=\max_{1\le k<n}T(k),\qquad z_t=\frac{y_t-\bar y}{s}

With your numbers

T0=7.50 at k=27,n=40,4999 null drawsT_0 = 7.50\ \text{at } k = 27,\quad n = 40,\quad 4999\text{ null draws}
zˉ1, zˉ2\bar z_1,\ \bar z_2
mean of the standardized series before and after k
max⁡k\max_k
the search over every split, paid for by simulating the maximum

The verdict

T₀ = 7.50, p = .069

p > α = .050: compatible with H₀

Built for independent normal data around one level; serial correlation or a trend also inflate T0. The located k is an estimate, not a date known in advance.

Statistic
7.501
p-value
0.0688
Standard normal homogeneity test on 40 (x, y) pairs: T0 = 7.50, p = .069. The p-value is above α = .050, so the data are compatible with H0.

Standard normal homogeneity test on 40 (x, y) pairs: T₀ = 7.50, p = .069. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: one constant normal mean; H1: one unknown mean shift.

Assumptions

Independent normal errors with common variance; a stable reference or standardized series when used for climate homogeneity.

Formula

T0=max⁡1≤k<n{kzˉ1:k 2+(n−k)zˉk+1:n 2}T_0=\max_{1\le k<n}\{k\bar z_{1:k}^{\,2}+(n-k)\bar z_{k+1:n}^{\,2}\}

Parameters and notation

zi=(xi−x̄)/s; subset means use the global mean and SD standardization.

Structure of the method

Standardize the entire record with a pooled mean and standard deviation, calculate the two segment-mean contrast at every candidate split, and maximize the resulting score. The computational structure is an unknown-break scan under a normal homogeneity null; the maximum needs search-adjusted reference values.

Estimated and nuisance parameters

Estimate full-sample location/scale and the candidate segment means; the maximizing position is a data-derived location estimate. When applying SNHT to differences or ratios against reference series, those constructed data and any reference-model estimates define a new analysis pipeline and must be described.

Settings and design choices

Choose the record/reference construction, eligible splits or minimum segment sizes, standardization convention, and Monte Carlo precision. Fixing a break date independently changes the problem to a fixed-break comparison. The cited function’s m controls simulated reference precision, not the strength or smoothness of a fitted shift.

Fitting and adaptation

Recompute global standardization and the full split search in each normal-null simulation. If adapting to environmental records with seasonality or serial dependence, justify preprocessing and calibrate its effect; simply using the word standardized does not make residuals independent Gaussian observations.

Sensitivity and robustness

Inspect endpoint behavior, autocorrelation, inhomogeneous variance, heavy tails, and differences between a step and a gradual trend. Comparing against a fixed-split chi-square threshold overstates evidence. Report the estimated break with uncertainty and substantive metadata rather than treating the argmax as a precisely known event time.

How to use and calibrate

Use SNHT critical values or normal-null simulation; the maximizing split estimates the candidate break.

Example application

Detect a station record discontinuity after relocation.

Interpretation and pitfalls

Watch out

The maximum requires search-adjusted calibration; ordinary fixed-split χ² values are invalid.

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

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.

Python · invokes R

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::snh.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()
R

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::snh.test(x))

Sources

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 233, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT233.