Skip to content

FTime to event · Guide test 146

Patwardhan exponentiality test

Uses normalized spacing information to test the exponential distribution.

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

Do it in CodeSplash

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

In Exponentiality tests (battery), choose Test = Patwardhan.

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 · Patwardhan exponentiality test

30
0.70

1 is exponential (a constant hazard); below 1 the hazard falls, above 1 it rises.

0.050

Your data

Drag a lifetime or change the shape
Lifetimes · n = 30 · mean 1.08

If H₀ were true

PA = 76.35
  1. The reference: how PA varies across samples when H₀ is true, PA under exponentiality, n = 30 (Monte Carlo null: 1,999 samples simulated under H₀ (seed 20261107)).
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = .059).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

Di=(n−i+1) (x(i)−x(i−1)),PA=n(n+1)∑iDi2(∑iDi)2D_i = (n - i + 1)\,(x_{(i)} - x_{(i-1)}),\qquad PA = \dfrac{n(n+1)\sum_i D_i^2}{\bigl(\sum_i D_i\bigr)^2}

With your numbers

PA=76.35(about 2n=60 under H0)PA = 76.35\qquad (\text{about } 2n = 60 \text{ under } H_0)
DiD_i
normalized spacings: independent exponentials when the data are exponential
PAPA
how unevenly the spacings are spread
x(i)x_{(i)}
the i-th smallest lifetime

The verdict

PA = 76.35, p = .059

p > α = .050: compatible with H₀

Large PA means a few gaps dominate: a heavier right tail than exponential. The null is simulated, so p comes from exponential samples of the same size.

Statistic
76.348
p-value
0.0585
Patwardhan exponentiality test on Lifetimes: n = 30: PA = 76.35, p = .059. The p-value is above α = .050, so the data are compatible with H0.

Patwardhan exponentiality test on Lifetimes: n = 30: PA = 76.35, p = .059. The p-value is above α = .050, so the data are compatible with H₀.

Question and hypotheses

H0: Xi are exponential with some common mean θ>0; H1: a departure detectable by this statistic.

Assumptions

Independent identically distributed positive, uncensored observations. The null is an exponential distribution with unknown scale and known origin zero. Censored, shifted or dependent samples need specialized versions.

Formula

P=n(n+1)∑iDi2(∑iDi)2P=\frac{n(n+1)\sum_iD_i^2}{(\sum_iD_i)^2}

Parameters and notation

Di=(n−i+1)[X(i)−X(i−1)], X(0)=0. Under H0 these normalized spacings are independent exponentials with the same mean. This is the normalized-spacing form used by EWGoF; its range is n+1 to n(n+1).

Structure of the method

Compute risk-set-weighted spacings, normalize their squared sum by the square of their total and multiply by the specified n-dependent factor. Under exponentiality the normalized spacing proportions have a Dirichlet structure, providing a convenient scale-free simulation basis.

Estimated and nuisance parameters

No explicit rate estimation is needed because spacing scale cancels. The spacing concentration is a computed sample functional; n and the known origin determine its normalization and range.

Settings and design choices

Fix the exact normalized-spacing form, upper-tail rule, significance level and simulation count. A raw-observation coefficient of variation or variance ratio is a different statistic and cannot use this calibration.

Fitting and adaptation

There is no neural fitting or fine-tuning stage. For an unknown-scale exponential null, exploit scale invariance or re-estimate the mean in every simulated unit-exponential sample, exactly matching the observed-data algorithm. Calibrate the prespecified tail and repeat the entire procedure after changing a tuning rule. Report simulation count and Monte Carlo uncertainty; use a plus-one randomized p-value convention for newly implemented Monte Carlo tests.

Sensitivity and robustness

Unusually uneven spacings raise the statistic, but rounding can generate zero spacings and artificial concentration. A common origin and complete uncensored observation are essential. The analytic range n+1 to n(n+1) provides an implementation check, while a value inside that range does not itself validate distributional assumptions.

How to use and calibrate

Use an upper-tail Monte Carlo exponential reference at the observed n.

Example application

Detect unusually uneven normalized spacings in complete lifetime data.

Interpretation and pitfalls

Watch out

The catalog’s short description referred to spacings; the method is also derived from exponential probability plots. State the exact form rather than confusing it with a raw-sample variance ratio.

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

Patwardhan normalized-spacing statistic with upper-tail Monte Carlo calibration; the sample mean/scale cancels.

Python · invokes R

Not run — Executed end to end through Rscript · needs Python standard library + Rscript; R packages: base R

# 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<-rexp(30,rate=2)
PA<-function(x) {n<-length(x);D<-rev(seq_len(n))*diff(c(0,sort(x)));n*(n+1)*sum(D^2)/sum(D)^2}
T<-PA(x);B<-999;null<-replicate(B,PA(rexp(length(x))))
print(c(statistic=T,p=(1+sum(null>=T))/(B+1)))
"""
# 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

Validated — Executed successfully in the validation environment · needs Base/standard library

set.seed(2026)
x<-rexp(30,rate=2)
PA<-function(x) {n<-length(x);D<-rev(seq_len(n))*diff(c(0,sort(x)));n*(n+1)*sum(D^2)/sum(D)^2}
T<-PA(x);B<-999;null<-replicate(B,PA(rexp(length(x))))
print(c(statistic=T,p=(1+sum(null>=T))/(B+1)))
Output
statistic         p 
 86.18681   0.02000

Sources

Statistics guide v4 (historical):
Python: Executed end to end through Rscript · R: Executed successfully in the validation 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 146, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT146.