FTime to event · Guide test 146
Patwardhan exponentiality test
Uses normalized spacing information to test the exponential distribution.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Exponentiality tests (battery) — Could these lifetimes be exponential, with a constant failure rate?
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
1 is exponential (a constant hazard); below 1 the hazard falls, above 1 it rises.
Your data
Drag a lifetime or change the shapeIf H₀ were true
- 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)).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .059).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The formula
With your numbers
- normalized spacings: independent exponentials when the data are exponential
- how unevenly the spacings are spread
- 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 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
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.
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()
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
- EWGoF — EWGoF · EDF_NS.testAuthor documentation/source reviewed: EWGoF 2.2.2.search.r-project.org
- EDF_NS.testsearch.r-project.org
- 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.