GQuality & process · life.exponentiality
Exponentiality tests (battery)
Could these lifetimes be exponential, with a constant failure rate?
All nineteen exponentiality tests of the statistics guide plus Baringhaus–Henze, Shapiro–Wilk W, the estimated-rate EDF tests, the total-time-on-test area and Proschan–Pyke, side by side on complete lifetimes. Reports how many reject, a p-value adjusted for running them all, the mean life with an exact interval, and a scaled TTT plot that shows the direction of any departure. The null is simulated on one shared random stream, so Python and R count the same samples.
A real result
Example “Battery exp sim”, recorded in both engines. In the app, “Try this example” loads it into Analyze.
Cox–Oakes = −2.17, p = .720
- Mean life
- 0.8592
- Failure rate
- 1.164
- Tests rejecting
- 2
- p, adjusted for the battery
- .220
- Tests run
- 30
Plots
View data
| x |
|---|
| 0.1987 |
| 0.0565 |
| 0.7537 |
| 0.4180 |
| 0.0554 |
| 2.037 |
| 0.4341 |
| 0.0808 |
| 2.685 |
| 0.1919 |
| 0.7465 |
| 0.5602 |
| 0.0452 |
| 3.232 |
| 0.4822 |
| 1.786 |
| 0.5297 |
| 0.5335 |
| 0.7144 |
| 0.9352 |
| 0.6679 |
| 0.7535 |
| 2.622 |
| 0.1017 |
View data
| Series | Fitted F(t) | x |
|---|---|---|
| data | — | 0.1987 |
| data | — | 0.0565 |
| data | — | 0.7537 |
| data | — | 0.4180 |
| data | — | 0.0554 |
| data | — | 2.037 |
| data | — | 0.4341 |
| data | — | 0.0808 |
| data | — | 2.685 |
| data | — | 0.1919 |
| data | — | 0.7465 |
| data | — | 0.5602 |
| data | — | 0.0452 |
| data | — | 3.232 |
| data | — | 0.4822 |
| data | — | 1.786 |
| data | — | 0.5297 |
| data | — | 0.5335 |
| data | — | 0.7144 |
| data | — | 0.9352 |
| data | — | 0.6679 |
| data | — | 0.7535 |
| data | — | 2.622 |
| data | — | 0.1017 |
| exponential | 0.0513 | 0.0452 |
| exponential | 0.1091 | 0.0992 |
| exponential | 0.1633 | 0.1532 |
| exponential | 0.2143 | 0.2073 |
| exponential | 0.2622 | 0.2613 |
| exponential | 0.3072 | 0.3153 |
| exponential | 0.3494 | 0.3693 |
| exponential | 0.3890 | 0.4233 |
| exponential | 0.4263 | 0.4774 |
| exponential | 0.4612 | 0.5314 |
| exponential | 0.4940 | 0.5854 |
| exponential | 0.5249 | 0.6394 |
| exponential | 0.5538 | 0.6934 |
| exponential | 0.5810 | 0.7475 |
| exponential | 0.6065 | 0.8015 |
| exponential | 0.6305 | 0.8555 |
| exponential | 0.6530 | 0.9095 |
| exponential | 0.6742 | 0.9635 |
| exponential | 0.6940 | 1.018 |
| exponential | 0.7127 | 1.072 |
| exponential | 0.7302 | 1.126 |
| exponential | 0.7466 | 1.180 |
| exponential | 0.7621 | 1.234 |
| exponential | 0.7766 | 1.288 |
| exponential | 0.7902 | 1.342 |
| exponential | 0.8030 | 1.396 |
| exponential | 0.8150 | 1.450 |
| exponential | 0.8262 | 1.504 |
| exponential | 0.8368 | 1.558 |
| exponential | 0.8468 | 1.612 |
| exponential | 0.8561 | 1.666 |
| exponential | 0.8649 | 1.720 |
| exponential | 0.8731 | 1.774 |
| exponential | 0.8808 | 1.828 |
| exponential | 0.8881 | 1.882 |
| exponential | 0.8949 | 1.936 |
First 60 of 84 rows.
View data
| x |
|---|
| 0.1987 |
| 0.0565 |
| 0.7537 |
| 0.4180 |
| 0.0554 |
| 2.037 |
| 0.4341 |
| 0.0808 |
| 2.685 |
| 0.1919 |
| 0.7465 |
| 0.5602 |
| 0.0452 |
| 3.232 |
| 0.4822 |
| 1.786 |
| 0.5297 |
| 0.5335 |
| 0.7144 |
| 0.9352 |
| 0.6679 |
| 0.7535 |
| 2.622 |
| 0.1017 |
Assumptions
- Independent lifetimes — Not testable from these numbers alone; check how the units were sampled.
- Complete lifetimes — All 24 values are treated as failures. For censored units use Distribution ID.
- No tied lifetimes — All lifetimes are distinct.
Exponentiality tests
| Test | Statistic | z | p (reference) | p (simulated) | p used | p adjusted | Rejects at .05 |
|---|---|---|---|---|---|---|---|
| Cox–Oakes | −2.174 | −0.3460 | .729 | .720 | .720 | — | no |
| Epps–Pulley | 0.5174 | 0.5911 | .554 | .570 | .570 | — | no |
| Henze–Meintanis (exponential weight) | 0.1498 | — | — | .280 | .280 | — | no |
| Henze–Meintanis (Gaussian weight) | 0.0511 | — | — | .365 | .365 | — | no |
| Meintanis–Iliopoulos (exponential weight) | 1.116 | — | — | .260 | .260 | — | no |
| Meintanis–Iliopoulos (Gaussian weight) | 0.1838 | — | — | .265 | .265 | — | no |
| Gnedenko F | 0.8590 | — | .713 | .790 | .790 | — | no |
| Harris | 1.623 | — | .242 | .230 | .230 | — | no |
| Hegazy–Green T₁ | 0.2145 | — | — | .155 | .155 | — | no |
| Hegazy–Green T₂ | 0.1026 | — | — | .280 | .280 | — | no |
| Hollander–Proschan | 0.2600 | 0.4575 | .647 | .660 | .660 | — | no |
| Deshpande | 0.6721 | −0.7326 | .464 | .430 | .430 | — | no |
| Atkinson | 0.0025 | 0.4598 | .646 | .630 | .630 | — | no |
| Ahsanullah | 0.0346 | 0.4587 | .646 | .635 | .635 | — | no |
| Epstein (Bartlett) | 35.996 | — | .041 | .035 | .035 | — | yes |
| Frosini | 0.2454 | — | — | .320 | .320 | — | no |
| Kimber–Michael | 0.0978 | — | — | .400 | .400 | — | no |
| Kochar | 0.3994 | 0.3994 | .690 | .800 | .800 | — | no |
| Moran | −0.0402 | −0.2453 | .806 | .790 | .790 | — | no |
| Rossberg | 0.0219 | 0.4999 | .617 | .635 | .635 | — | no |
| Gini | 0.5447 | 0.7434 | .457 | .435 | .435 | — | no |
| Patwardhan | 63.558 | — | — | .035 | .035 | — | yes |
| Baringhaus–Henze | 0.0255 | — | — | .625 | .625 | — | no |
| Shapiro–Wilk W for exponentiality | 0.0359 | — | — | .480 | .480 | — | no |
| Lilliefors (Kolmogorov–Smirnov, rate estimated) | 0.1660 | — | — | .230 | .230 | — | no |
| Anderson–Darling (rate estimated) | 0.5819 | — | — | .330 | .330 | — | no |
| Cramér–von Mises (rate estimated) | 0.0906 | — | — | .370 | .370 | — | no |
| Watson U² (rate estimated) | 0.0833 | — | — | .295 | .295 | — | no |
| Total time on test (area under the TTT plot) | 0.4553 | −0.7434 | .457 | .435 | .435 | — | no |
| Proschan–Pyke | 128 | −0.4961 | .620 | .615 | .615 | — | no |
Mean life under the exponential model
| Mean life | 95% CI low | 95% CI high | Failure rate |
|---|---|---|---|
| 0.8592 | 0.5975 | 1.341 | 1.164 |
- Simulated p-values compare each statistic with 199 exponential samples of the same size (seed 42), renormalized as in the data; every test sees the same samples.
- The count of rejections is not a combined test: the tests overlap, so about 3 in 10 exponential samples get at least one. The adjusted p asks how often exponential samples of this size give a smallest p-value this small across all the tests (single-step min-p, Westfall & Young 1993).
- The total-time-on-test area equals one minus the Gini statistic.
- A Gini statistic below one half and a TTT plot above the diagonal point to a rising failure rate; the reverse points to a falling one.
Cox–Oakes = −2.17, p = .720
- Mean life
- 0.8592
- Failure rate
- 1.164
- Tests rejecting
- 2
- p, adjusted for the battery
- .220
- Tests run
- 30
To keep this page light, the plots are shown once, under the R tab.
Assumptions
- Independent lifetimes — Not testable from these numbers alone; check how the units were sampled.
- Complete lifetimes — All 24 values are treated as failures. For censored units use Distribution ID.
- No tied lifetimes — All lifetimes are distinct.
Exponentiality tests
| Test | Statistic | z | p (reference) | p (simulated) | p used | p adjusted | Rejects at .05 |
|---|---|---|---|---|---|---|---|
| Cox–Oakes | −2.174 | −0.3460 | .729 | .720 | .720 | 1.000 | no |
| Epps–Pulley | 0.5174 | 0.5911 | .554 | .570 | .570 | 1.000 | no |
| Henze–Meintanis (exponential weight) | 0.1498 | — | — | .280 | .280 | .820 | no |
| Henze–Meintanis (Gaussian weight) | 0.0511 | — | — | .365 | .365 | .920 | no |
| Meintanis–Iliopoulos (exponential weight) | 1.116 | — | — | .260 | .260 | .795 | no |
| Meintanis–Iliopoulos (Gaussian weight) | 0.1838 | — | — | .265 | .265 | .800 | no |
| Gnedenko F | 0.8590 | — | .713 | .790 | .790 | 1.000 | no |
| Harris | 1.623 | — | .242 | .230 | .230 | .765 | no |
| Hegazy–Green T₁ | 0.2145 | — | — | .155 | .155 | .650 | no |
| Hegazy–Green T₂ | 0.1026 | — | — | .280 | .280 | .820 | no |
| Hollander–Proschan | 0.2600 | 0.4575 | .647 | .660 | .660 | 1.000 | no |
| Deshpande | 0.6721 | −0.7326 | .464 | .430 | .430 | .975 | no |
| Atkinson | 0.0025 | 0.4598 | .646 | .630 | .630 | 1.000 | no |
| Ahsanullah | 0.0346 | 0.4587 | .646 | .635 | .635 | 1.000 | no |
| Epstein (Bartlett) | 35.996 | — | .041 | .035 | .035 | .220 | yes |
| Frosini | 0.2454 | — | — | .320 | .320 | .885 | no |
| Kimber–Michael | 0.0978 | — | — | .400 | .400 | .955 | no |
| Kochar | 0.3994 | 0.3994 | .690 | .800 | .800 | 1.000 | no |
| Moran | −0.0402 | −0.2453 | .806 | .790 | .790 | 1.000 | no |
| Rossberg | 0.0219 | 0.4999 | .617 | .635 | .635 | 1.000 | no |
| Gini | 0.5447 | 0.7434 | .457 | .435 | .435 | .975 | no |
| Patwardhan | 63.558 | — | — | .035 | .035 | .220 | yes |
| Baringhaus–Henze | 0.0255 | — | — | .625 | .625 | 1.000 | no |
| Shapiro–Wilk W for exponentiality | 0.0359 | — | — | .480 | .480 | .980 | no |
| Lilliefors (Kolmogorov–Smirnov, rate estimated) | 0.1660 | — | — | .230 | .230 | .765 | no |
| Anderson–Darling (rate estimated) | 0.5819 | — | — | .330 | .330 | .895 | no |
| Cramér–von Mises (rate estimated) | 0.0906 | — | — | .370 | .370 | .925 | no |
| Watson U² (rate estimated) | 0.0833 | — | — | .295 | .295 | .845 | no |
| Total time on test (area under the TTT plot) | 0.4553 | −0.7434 | .457 | .435 | .435 | .975 | no |
| Proschan–Pyke | 128 | −0.4961 | .620 | .615 | .615 | 1.000 | no |
Mean life under the exponential model
| Mean life | 95% CI low | 95% CI high | Failure rate |
|---|---|---|---|
| 0.8592 | 0.5975 | 1.341 | 1.164 |
- Simulated p-values compare each statistic with 199 exponential samples of the same size (seed 42), renormalized as in the data; every test sees the same samples.
- The count of rejections is not a combined test: the tests overlap, so about 3 in 10 exponential samples get at least one. The adjusted p asks how often exponential samples of this size give a smallest p-value this small across all the tests (single-step min-p, Westfall & Young 1993).
- The total-time-on-test area equals one minus the Gini statistic.
- A Gini statistic below one half and a TTT plot above the diagonal point to a rising failure rate; the reverse points to a falling one.
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
- Battery exp simlife_exp_sim · outcome: x
- Battery wearlife_wear_sim · outcome: x
- Battery bearings tieslife_bearings · outcome: revs
- Cox oakeslife_exp_sim · outcome: x
- Epps pulleylife_exp_sim · outcome: x
- Henze meintanislife_exp_sim · outcome: x
- Henze meintanis gausslife_exp_sim · outcome: x
- Meintanis iliopouloslife_exp_sim · outcome: x
In the guides
Tests from the statistics guide this method runs
Where it sits in the decision guides
- Parametric models: Weibull, exponential … · Statistics Guide · F — Time-to-event analysis
What you need
- Lifetimenumeric · 1 column
- Complete lifetimes or times between failures, all positive. Censored units belong in Distribution ID.
Choices you make
hypothesis
- Testdefault battery
H₀: exponential with some mean. Run every test, or one chosen in advance.
- Battery (all 30 tests)(default) — Every test side by side, how many reject, and a p adjusted for running them all. Judge the battery by that p, not by the count.
- Cox–Oakes — A score test against Weibull alternatives; sensitive to shape above or below 1.
- Epps–Pulley — Compares the sample's Laplace transform at one with its exponential value of one half.
- Moran — Based on the mean log lifetime; the efficient test against gamma alternatives.
- Atkinson — Compares a power mean with its exponential value, for a tuning power you set.
- Gini — The Gini coefficient of the lifetimes is one half under the null; above means decreasing hazard, below increasing.
- Kochar — An L-statistic built to detect increasing failure rate in average.
- Henze–Meintanis, exponential weight — Weighted distance between the empirical characteristic function's modulus and real part; exponential weight.
- Henze–Meintanis, Gaussian weight — The same distance with a Gaussian weight.
- Meintanis–Iliopoulos, exponential weight — Weighted distance of the sine–cosine characterization of the exponential; exponential weight.
- Meintanis–Iliopoulos, Gaussian weight — The same characterization with a Gaussian weight.
- Baringhaus–Henze — Based on the differential equation the exponential's Laplace transform satisfies.
- Gnedenko F — Early against late normalized spacings; an exact F test that detects monotone hazards.
- Harris — Both tails of the normalized spacings against the middle; detects bathtub-shaped hazards.
- Epstein (Bartlett) — Bartlett's homogeneity test on the normalized spacings, against any heterogeneous failure rate.
- Patwardhan — The squared coefficient of variation of the normalized spacings.
- Proschan–Pyke — Counts how often an earlier normalized spacing exceeds a later one; detects increasing failure rate.
- Total time on test (area) — The area under the scaled TTT plot, Klefsjö's graphical test as a number. It equals one minus the Gini statistic.
- Hollander–Proschan — New better than used: how often one unit outlives the sum of two others.
- Deshpande — How often one unit outlives b times another, for a tuning b you set.
- Ahsanullah — Compares the distribution of differences with that of doubled minima.
- Rossberg — Compares gaps between the two smallest of three with minima of two.
- Shapiro–Wilk W — Ratio of the squared mean excess over the minimum to the variance; both tails reject.
- Lilliefors (KS, rate estimated) — Kolmogorov–Smirnov distance with the rate estimated; the null is simulated with re-estimation.
- Anderson–Darling (rate estimated) — An EDF distance that weights the tails more.
- Cramér–von Mises (rate estimated) — An EDF distance that weights the whole range evenly.
- Watson U² (rate estimated) — Cramér–von Mises with the mean difference removed, for curvature in the fit.
- Hegazy–Green T₁ — Mean absolute distance between ordered lifetimes and exponential scores.
- Hegazy–Green T₂ — Mean squared distance between ordered lifetimes and exponential scores.
- Frosini — Sum of absolute gaps between fitted probabilities and midpoint plotting positions.
- Kimber–Michael — Largest gap on the arcsine-root scale, which evens out the weight along the curve.
- p-valuesdefault auto
Simulation holds its error rate at any size. Some papers' reference distributions reject too often below about 300 lifetimes.
- Simulate up to n = 300, then reference(default) — Tests with a paper's reference distribution switch to it above 300 values; the others keep simulating.
- Always simulate — Simulate every test at any n; slower for large samples.
- Reference where available — Use the paper's normal, F or chi-square reference when there is one. Too liberal below about 300 lifetimes for some tests.
- Simulated samplesdefault 999
Exponential samples simulated for each p-value (shared seeded stream, same in Python and R). More gives steadier p-values.
statistics
- Confidence leveldefault 0.95
How sure the interval for the mean life should be, under the exponential model.
Advanced
- Weight a (transform tests)default 1
Tuning of the weight function in Henze–Meintanis, Meintanis–Iliopoulos and Baringhaus–Henze. Fix it before looking at results.
- Deshpande bdefault 0.44
How much longer one unit must outlive another; any positive value but 1. Fix it before looking at results.
- Atkinson powerdefault 0.99
Power of the power mean, above −0.5 and not 0 or 1. Fix it before looking at results.
- Gnedenko splitdefault —
How many early spacings go in the numerator. Choose it before looking at results.
- Harris splitdefault —
How many spacings at each end go in the numerator. Choose it before looking at results.
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.
Independent lifetimes
One lifetime per unit, or times between failures of a process that renews itself at each repair.
Complete lifetimes
Every unit was followed to failure; these tests have no allowance for censoring.
No tied lifetimes
Exponential lifetimes are continuous; ties make the spacing tests lose information or fail to compute.
What it reports
- n
- How many independent units the analysis used; it sets precision and power.
- mean
- The sum divided by the count; the balance point of the data, pulled by extreme values.
- mean_low
- A range of effect values compatible with your data at the chosen confidence level.
- mean_high
- A range of effect values compatible with your data at the chosen confidence level.
- rate
- Events per unit of time or exposure. For exponential lifetimes it is one over the mean life.
- min
- The smallest and largest values in the sample.
- max
- The smallest and largest values in the sample.
- n_tests
- How many independent units the analysis used; it sets precision and power.
- n_reject
- How many independent units the analysis used; it sets precision and power.
- battery_p
- How often null samples give a smallest p-value this small across the tests. Unlike the rejection count, it allows for running them all.
- n_reject_adj
- How often null samples give a smallest p-value this small across the tests. Unlike the rejection count, it allows for running them all.
- adjust_method
- How often null samples give a smallest p-value this small across the tests. Unlike the rejection count, it allows for running them all.
- n_not_computed
- How many independent units the analysis used; it sets precision and power.
- test_label
- The exact variant that ran (for example Welch vs classic F), shown so the result can be reported and reproduced.
- verdict
- The result in words, at the significance level stated with it. It says what the data are compatible with, not what is true.
- lead_label
- The test the summary quotes. It is the one you chose, or Cox–Oakes when the whole battery runs.
- lead_stat
- The test the summary quotes. It is the one you chose, or Cox–Oakes when the whole battery runs.
- lead_p
- The test the summary quotes. It is the one you chose, or Cox–Oakes when the whole battery runs.
- gini
- The Gini coefficient of the lifetimes. It is one half for exponential data; above means a falling hazard, below a rising one.
- reps
- How many samples were simulated for a p-value. More gives a steadier p-value; it does not change what is tested.
Per group, level or term: stat[<test>], z[<test>], p[<test>], p_ref[<test>], p_mc[<test>], p_adj[<test>], calibration[<test>]
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
- Atkinson's statistic subtracts two nearly equal numbers, so last-digit rounding in the gamma function shows up at about 1e-10: its keys, including its adjusted p, have a looser tolerance.
- Every simulated p-value uses unit exponentials from the shared Wichmann–Hill stream, so both engines count the same samples (P0).
- Henze–Meintanis uses the guide's integral over t > 0; EWGoF::CF.test integrates over the whole line, so its W statistics are exactly twice these. The p-values are unaffected.
- Under H0 the 30 tests give 1.5 rejections on average, and at least one in 27–31% of samples at n = 10–100 (4,000 simulated samples at each size), because they overlap. The verdict therefore rests on battery_p: exact single-step min-p (Westfall & Young 1993) over the shared null samples when every test was simulated, Bonferroni when any test uses a reference distribution.
- The total-time-on-test area equals one minus the Gini statistic, so those two rows always give the same p-value. Klefsjö's named weighted statistics are not implemented: the guide gives no formula, and only the TTT area, which his papers also use, is reported.
The exact script CodeSplash ran for example “Battery exp sim” · Python 3.13.5 · scipy 1.18.1 · pandas 3.1.0
# Exponentiality tests (battery)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method life.exponentiality 1.0.2 · spec a5605ed2018fe15e
# Dataset: life_exp_sim (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
from scipy import stats
import codesplash as cs
from codesplash.stats import exponentiality as ex # the tests, written from the papers; shared random stream
# %% Data
df = pd.read_parquet("tests/parity/fixtures/life_exp_sim.parquet", columns=["x"])
n_input = len(df)
df = df.dropna(subset=["x"]) # 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, ["x"]) # infinite values stop the run (registry/errors.yaml)
# %% Tests
y = "x"
x = df[y].to_numpy(dtype=float)
x = x[~np.isnan(x)]
if (x <= 0).any():
cs.cs_error("CS_E_INVALID_VALUES", column=y, requirement="positive (lifetimes above zero)", count=int((x <= 0).sum()))
n = x.size
cs.check_rows(n, 5, "The exponentiality tests") # the battery needs at least 5 lifetimes
test = "battery"
alpha = 0.05
seed, reps = 42, int(199) # exponential samples from the shared Wichmann–Hill stream
a, b, power = 1, 0.44, 0.99
if b == 1:
raise ValueError("Deshpande's b must differ from 1")
if power in (0, 1):
raise ValueError("Atkinson's power cannot be 0 or 1")
rows = ex.exp_battery(
x, tests=None if test == "battery" else [test], calibration="auto", reps=reps, seed=seed, a=a, b=b, power=power,
r_gnedenko=None,
r_harris=None,
)
tested = [r for r in rows if np.isfinite(r["p"])]
rejecting = [r for r in tested if r["p"] < alpha]
# About 1.5 of 30 tests reject by chance, and because they overlap, some rejection turns up in about 3 of every 10
# truly exponential samples. So the verdict rests on the p adjusted for running them all, not on the count.
adjust_method = rows[0]["adjust"]
battery_p = min((r["p_adj"] for r in tested), default=float("nan"))
if n < 300 and any(r["calibration"] == "reference" and r["key"] in ("kochar", "ahsanullah", "rossberg", "deshpande") for r in rows):
warnings.append("Reference distributions reject too often below about 300 lifetimes: Kochar 12%, Ahsanullah 11% and Rossberg 10% at the 5% level with 30 lifetimes. Simulate instead.")
# %% Mean life under the exponential model (exact chi-square interval)
conf = 0.95
mean = float(x.mean())
mean_low = 2 * n * mean / float(stats.chi2.ppf(1 - (1 - conf) / 2, 2 * n))
mean_high = 2 * n * mean / float(stats.chi2.ppf((1 - conf) / 2, 2 * n))
order = np.sort(x)
gini = float(2 * np.sum((2 * np.arange(1, n + 1) - n - 1) * order) / (2 * n * (n - 1) * mean))
# %% Verdict and values
lead = next((r for r in rows if r["key"] == "cox_oakes"), rows[0])
if len(rows) == 1:
verdict = "exponentiality rejected at α = .05" if lead["p"] < alpha else "compatible with an exponential distribution"
elif not rejecting:
verdict = "the lifetimes are compatible with a constant failure rate"
elif not battery_p < alpha:
verdict = "that is what chance gives across this many overlapping tests, so the lifetimes are compatible with a constant failure rate"
elif not next(r for r in rows if r["key"] == "gini")["p"] < alpha:
verdict = "the lifetimes depart from an exponential, with no clear rising or falling failure rate"
elif gini < 0.5:
verdict = "the departure looks like a rising failure rate (wear-out)"
else:
verdict = "the departure looks like a falling failure rate (early failures)"
values = {"n": n, "mean": mean, "mean_low": mean_low, "mean_high": mean_high, "rate": 1 / mean, "min": float(x.min()), "max": float(x.max()),
"n_tests": len(tested), "n_reject": len(rejecting), "n_not_computed": len(rows) - len(tested),
"battery_p": battery_p, "n_reject_adj": sum(1 for r in tested if r["p_adj"] < alpha), "adjust_method": adjust_method,
"test_label": lead["test"] if len(rows) == 1 else "Battery", "verdict": verdict, "lead_label": lead["test"], "lead_stat": lead["statistic"], "lead_p": lead["p"],
"gini": gini, "reps": reps}
def cell(v):
"""A table cell: a number the test does not have shows a dash, not NaN."""
return float(v) if np.isfinite(v) else None
table = []
for r in rows:
k = r["key"]
values[f"stat[{k}]"], values[f"z[{k}]"], values[f"p[{k}]"] = r["statistic"], r["z"], r["p"]
values[f"p_ref[{k}]"], values[f"p_mc[{k}]"], values[f"calibration[{k}]"] = r["p_ref"], r["p_mc"], r["calibration"]
values[f"p_adj[{k}]"] = r["p_adj"]
computed = bool(np.isfinite(r["p"]))
table.append({"test": r["test"], "statistic": cell(r["statistic"]), "z": cell(r["z"]), "p_ref": cell(r["p_ref"]), "p_mc": cell(r["p_mc"]), "p": cell(r["p"]), "p_adj": cell(r["p_adj"]),
"reject": ("yes" if r["p"] < alpha else "no") if computed else "not computed"})
# %% Assumptions
tied = n - np.unique(x).size
assumptions = [
{"key": "independence", "label": "Independent lifetimes", "status": "info", "detail": "Not testable from these numbers alone; check how the units were sampled."},
{"key": "complete_data", "label": "Complete lifetimes", "status": "info", "detail": f"All {n} values are treated as failures. For censored units use Distribution ID."},
{"key": "ties", "label": "No tied lifetimes", "status": "warn" if tied else "pass",
"detail": f"{tied} tied value(s): zero spacings stop the Epstein test and weaken the other spacing tests." if tied else "All lifetimes are distinct."},
]
# %% Charts
pct = f"{conf:.0%}"
fit_t = np.linspace(float(x.min()), float(x.max()), 60)
charts = [
cs.chart("ttt", "ttt-plot", f"Scaled total-time-on-test plot: {y}", {"value": cs.col(y, x, "numeric")}),
cs.chart("paper", "probability-plot", f"Exponential probability plot: {y}", {
"time": cs.col(y, np.concatenate((x, fit_t)), "numeric"),
"fit": cs.col("Fitted F(t)", np.concatenate((np.full(n, np.nan), -np.expm1(-fit_t / mean))), "numeric"),
"family": cs.col("Series", ["data"] * n + ["exponential"] * fit_t.size, "categorical", levels=["data", "exponential"]),
}, controls={"paper": "exponential"}),
cs.chart("lorenz", "lorenz-gini", f"Lorenz curve: {y}", {"value": cs.col(y, x, "numeric")}),
]
# %% Result
cs.publish({
"method": "life.exponentiality",
"methodVersion": "1.0.2",
"title": "Exponentiality tests" if len(rows) > 1 else f"Exponentiality: {lead['test']}",
"engine": cs.engine_info("numpy", "scipy", "codesplash"),
"n": int(n),
"summary": (f"{len(rejecting)} of {len(tested)} tests reject exponentiality at α = .05; adjusted for running all {len(tested)}, {cs.fmt_p(battery_p)}: {verdict}." if len(rows) > 1
else f"{lead['test']}: {cs.fmt_p(lead['p'])}; {verdict}."),
"apa": f"{lead['test']} = {cs.fmt_num(lead['statistic'])}, {cs.fmt_p(lead['p'])}",
"statistics": [{"key": "mean", "label": "Mean life", "value": mean}, {"key": "rate", "label": "Failure rate", "value": 1 / mean},
{"key": "n_reject", "label": "Tests rejecting", "value": len(rejecting), "format": "integer"},
{"key": "battery_p", "label": "p, adjusted for the battery", "value": battery_p, "format": "p"},
{"key": "n_tests", "label": "Tests run", "value": len(tested), "format": "integer"}],
"tables": [
{"key": "tests", "title": "Exponentiality tests", "columns": [
{"key": "test", "label": "Test", "type": "string"}, {"key": "statistic", "label": "Statistic", "type": "number"},
{"key": "z", "label": "z", "type": "number"}, {"key": "p_ref", "label": "p (reference)", "type": "pvalue"},
{"key": "p_mc", "label": "p (simulated)", "type": "pvalue"}, {"key": "p", "label": "p used", "type": "pvalue"},
{"key": "p_adj", "label": "p adjusted", "type": "pvalue"},
{"key": "reject", "label": "Rejects at .05", "type": "string"}], "rows": table},
{"key": "mean_life", "title": "Mean life under the exponential model", "columns": [
{"key": "mean", "label": "Mean life", "type": "number"}, {"key": "low", "label": f"{pct} CI low", "type": "number"},
{"key": "high", "label": f"{pct} CI high", "type": "number"}, {"key": "rate", "label": "Failure rate", "type": "number"}],
"rows": [{"mean": mean, "low": mean_low, "high": mean_high, "rate": 1 / mean}]},
],
"effectSizes": [],
"assumptions": assumptions,
"warnings": warnings,
"notes": [
f"Simulated p-values compare each statistic with {reps} exponential samples of the same size (seed {seed}), renormalized as in the data; every test sees the same samples.",
("The count of rejections is not a combined test: the tests overlap, so about 3 in 10 exponential samples get at least one. The adjusted p asks how often exponential samples of this size give a smallest p-value this small across all the tests (single-step min-p, Westfall & Young 1993)." if adjust_method == "min_p"
else "The count of rejections is not a combined test: the tests overlap, so about 3 in 10 exponential samples get at least one. Some tests here use a reference distribution, so the adjusted p is Bonferroni, which is cautious for overlapping tests."),
"The total-time-on-test area equals one minus the Gini statistic.",
"A Gini statistic below one half and a TTT plot above the diagonal point to a rising failure rate; the reverse points to a falling one.",
],
"charts": charts,
"values": values,
})
The exact script CodeSplash ran for example “Battery exp sim” · R version 4.5.1 (2025-06-13)
# Exponentiality tests (battery)
# Generated by CodeSplash Analytics 1.0.0 on 2026-11-09 · method life.exponentiality 1.0.2 · spec a5605ed2018fe15e
# Dataset: life_exp_sim (version 1)
# Runs on its own: outside the app, cs_publish() writes $CS_RESULT_PATH or prints the result JSON.
# %% Setup
library(codesplashr) # the tests, written from the papers; shared random stream
# %% Data
df <- as.data.frame(nanoparquet::read_parquet("tests/parity/fixtures/life_exp_sim.parquet", col_select = c("x")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("x")]), , 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("x")) # infinite values stop the run (registry/errors.yaml)
# %% Tests
y <- "x"
x <- as.numeric(df[[y]])
x <- x[!is.na(x)]
if (any(x <= 0)) cs_error("CS_E_INVALID_VALUES", column = y, requirement = "positive (lifetimes above zero)", count = sum(x <= 0))
n <- length(x)
cs_check_rows(n, 5, "The exponentiality tests") # the battery needs at least 5 lifetimes
test <- "battery"
alpha <- 0.05
seed <- 42 # exponential samples from the shared Wichmann-Hill stream
reps <- as.integer(199)
a <- 1
b <- 0.44
power <- 0.99
if (b == 1) stop("Deshpande's b must differ from 1")
if (power %in% c(0, 1)) stop("Atkinson's power cannot be 0 or 1")
rows <- cs_exp_battery(x, tests = if (test == "battery") NULL else test, calibration = "auto", reps = reps, seed = seed, a = a, b = b, power = power,
r_gnedenko = NULL,
r_harris = NULL)
tested <- Filter(function(r) is.finite(r$p), rows)
rejecting <- Filter(function(r) r$p < alpha, tested)
# About 1.5 of 30 tests reject by chance, and because they overlap, some rejection turns up in about 3 of every 10
# truly exponential samples. So the verdict rests on the p adjusted for running them all, not on the count.
adjust_method <- rows[[1]]$adjust
battery_p <- if (length(tested)) min(vapply(tested, function(r) r$p_adj, numeric(1))) else NaN
if (n < 300 && any(vapply(rows, function(r) r$calibration == "reference" && r$key %in% c("kochar", "ahsanullah", "rossberg", "deshpande"), logical(1)))) {
warnings <- c(warnings, "Reference distributions reject too often below about 300 lifetimes: Kochar 12%, Ahsanullah 11% and Rossberg 10% at the 5% level with 30 lifetimes. Simulate instead.")
}
# %% Mean life under the exponential model (exact chi-square interval)
conf <- 0.95
mean_x <- mean(x)
mean_low <- 2 * n * mean_x / stats::qchisq(1 - (1 - conf) / 2, 2 * n)
mean_high <- 2 * n * mean_x / stats::qchisq((1 - conf) / 2, 2 * n)
gini <- 2 * sum((2 * seq_len(n) - n - 1) * sort(x)) / (2 * n * (n - 1) * mean_x)
# %% Verdict and values
keys <- vapply(rows, function(r) r$key, character(1))
lead <- if ("cox_oakes" %in% keys) rows[[which(keys == "cox_oakes")]] else rows[[1]]
verdict <- if (length(rows) == 1) {
if (is.finite(lead$p) && lead$p < alpha) "exponentiality rejected at α = .05" else "compatible with an exponential distribution"
} else if (!length(rejecting)) {
"the lifetimes are compatible with a constant failure rate"
} else if (!isTRUE(battery_p < alpha)) {
"that is what chance gives across this many overlapping tests, so the lifetimes are compatible with a constant failure rate"
} else if (!isTRUE(rows[[which(keys == "gini")]]$p < alpha)) {
"the lifetimes depart from an exponential, with no clear rising or falling failure rate"
} else if (gini < 0.5) {
"the departure looks like a rising failure rate (wear-out)"
} else {
"the departure looks like a falling failure rate (early failures)"
}
values <- list(n = n, mean = mean_x, mean_low = mean_low, mean_high = mean_high, rate = 1 / mean_x, min = min(x), max = max(x),
n_tests = length(tested), n_reject = length(rejecting), n_not_computed = length(rows) - length(tested),
battery_p = battery_p, n_reject_adj = sum(vapply(tested, function(r) r$p_adj < alpha, logical(1))), adjust_method = adjust_method,
test_label = if (length(rows) == 1) lead$test else "Battery", verdict = verdict, lead_label = lead$test, lead_stat = lead$statistic, lead_p = lead$p,
gini = gini, reps = reps)
cell <- function(v) if (is.finite(v)) v else NA_real_ # a number the test does not have shows a dash, not NaN
table <- list()
for (r in rows) {
k <- r$key
values[[sprintf("stat[%s]", k)]] <- r$statistic
values[[sprintf("z[%s]", k)]] <- r$z
values[[sprintf("p[%s]", k)]] <- r$p
values[[sprintf("p_ref[%s]", k)]] <- r$p_ref
values[[sprintf("p_adj[%s]", k)]] <- r$p_adj
values[[sprintf("p_mc[%s]", k)]] <- r$p_mc
values[[sprintf("calibration[%s]", k)]] <- r$calibration
table[[length(table) + 1]] <- list(test = r$test, statistic = cell(r$statistic), z = cell(r$z), p_ref = cell(r$p_ref), p_mc = cell(r$p_mc), p = cell(r$p),
reject = if (is.finite(r$p)) (if (r$p < alpha) "yes" else "no") else "not computed")
}
# %% Assumptions
tied <- n - length(unique(x))
assumptions <- list(
list(key = "independence", label = "Independent lifetimes", status = "info", detail = "Not testable from these numbers alone; check how the units were sampled."),
list(key = "complete_data", label = "Complete lifetimes", status = "info", detail = sprintf("All %d values are treated as failures. For censored units use Distribution ID.", n)),
list(key = "ties", label = "No tied lifetimes", status = if (tied) "warn" else "pass",
detail = if (tied) sprintf("%d tied value(s): zero spacings stop the Epstein test and weaken the other spacing tests.", tied) else "All lifetimes are distinct.")
)
# %% Charts
pct <- sprintf("%.0f%%", conf * 100)
fit_t <- seq(min(x), max(x), length.out = 60)
charts <- list(
cs_chart("ttt", "ttt-plot", sprintf("Scaled total-time-on-test plot: %s", y), list(value = cs_col(y, x, "numeric"))),
cs_chart("paper", "probability-plot", sprintf("Exponential probability plot: %s", y), list(
time = cs_col(y, c(x, fit_t), "numeric"),
fit = cs_col("Fitted F(t)", c(rep(NaN, n), -expm1(-fit_t / mean_x)), "numeric"),
family = cs_col("Series", c(rep("data", n), rep("exponential", length(fit_t))), "categorical", levels = c("data", "exponential"))
), controls = list(paper = "exponential")),
cs_chart("lorenz", "lorenz-gini", sprintf("Lorenz curve: %s", y), list(value = cs_col(y, x, "numeric")))
)
# %% Result
cs_publish(list(
method = "life.exponentiality",
methodVersion = "1.0.2",
title = if (length(rows) > 1) "Exponentiality tests" else paste0("Exponentiality: ", lead$test),
engine = cs_engine_info("stats", "codesplashr"),
n = n,
summary = if (length(rows) > 1) sprintf("%d of %d tests reject exponentiality at α = .05; adjusted for running all %d, %s: %s.", length(rejecting), length(tested), length(tested), cs_fmt_p(battery_p), verdict)
else sprintf("%s: %s; %s.", lead$test, cs_fmt_p(lead$p), verdict),
apa = sprintf("%s = %s, %s", lead$test, cs_fmt_num(lead$statistic), cs_fmt_p(lead$p)),
statistics = list(list(key = "mean", label = "Mean life", value = mean_x), list(key = "rate", label = "Failure rate", value = 1 / mean_x),
list(key = "n_reject", label = "Tests rejecting", value = length(rejecting), format = "integer"),
list(key = "battery_p", label = "p, adjusted for the battery", value = battery_p, format = "p"),
list(key = "n_tests", label = "Tests run", value = length(tested), format = "integer")),
tables = list(
list(key = "tests", title = "Exponentiality tests", columns = list(
list(key = "test", label = "Test", type = "string"), list(key = "statistic", label = "Statistic", type = "number"),
list(key = "z", label = "z", type = "number"), list(key = "p_ref", label = "p (reference)", type = "pvalue"),
list(key = "p_mc", label = "p (simulated)", type = "pvalue"), list(key = "p", label = "p used", type = "pvalue"),
list(key = "p_adj", label = "p adjusted", type = "pvalue"),
list(key = "reject", label = "Rejects at .05", type = "string")), rows = table),
list(key = "mean_life", title = "Mean life under the exponential model", columns = list(
list(key = "mean", label = "Mean life", type = "number"), list(key = "low", label = paste(pct, "CI low"), type = "number"),
list(key = "high", label = paste(pct, "CI high"), type = "number"), list(key = "rate", label = "Failure rate", type = "number")),
rows = list(list(mean = mean_x, low = mean_low, high = mean_high, rate = 1 / mean_x)))
),
effectSizes = list(),
assumptions = assumptions,
warnings = warnings,
notes = list(
sprintf("Simulated p-values compare each statistic with %d exponential samples of the same size (seed %d), renormalized as in the data; every test sees the same samples.", reps, as.integer(seed)),
if (adjust_method == "min_p") "The count of rejections is not a combined test: the tests overlap, so about 3 in 10 exponential samples get at least one. The adjusted p asks how often exponential samples of this size give a smallest p-value this small across all the tests (single-step min-p, Westfall & Young 1993)."
else "The count of rejections is not a combined test: the tests overlap, so about 3 in 10 exponential samples get at least one. Some tests here use a reference distribution, so the adjusted p is Bonferroni, which is cautious for overlapping tests.",
"The total-time-on-test area equals one minus the Gini statistic.",
"A Gini statistic below one half and a TTT plot above the diagonal point to a rising failure rate; the reverse points to a falling one."
),
charts = charts,
values = values
))
Sources
- Henze, N., & Meintanis, S. G. (2005). Recent and classical tests for exponentiality: a partial review with comparisons. Metrika, 61, 29–45.
- Cox, D. R., & Oakes, D. (1984). Analysis of survival data. Chapman & Hall.
- Epps, T. W., & Pulley, L. B. (1986). A test of exponentiality vs. monotone-hazard alternatives derived from the empirical characteristic function. JRSS B, 48, 206–213.
- Baringhaus, L., & Henze, N. (1991). A class of consistent tests for exponentiality based on the empirical Laplace transform. Annals of the Institute of Statistical Mathematics, 43, 551–564.
- Meintanis, S. G., & Iliopoulos, G. (2003). Tests of fit for the Rayleigh distribution based on the empirical Laplace transform. Annals of the Institute of Statistical Mathematics, 55, 137–151.
- Gnedenko, B. V., Belyayev, Y. K., & Solovyev, A. D. (1969). Mathematical methods of reliability theory. Academic Press.
- Harris, C. M. (1976). A note on testing for exponentiality. Naval Research Logistics Quarterly, 23, 169–175.
- Hegazy, Y. A. S., & Green, J. R. (1975). Some new goodness-of-fit tests using order statistics. Applied Statistics, 24, 299–308.
- Hollander, M., & Proschan, F. (1972). Testing whether new is better than used. Annals of Mathematical Statistics, 43, 1136–1146.
- Deshpande, J. V. (1983). A class of tests for exponentiality against increasing failure rate average alternatives. Biometrika, 70, 514–518.
- Atkinson, A. B. (1970). On the measurement of inequality. Journal of Economic Theory, 2, 244–263.
- Ahsanullah, M. (1978). On a characterization of the exponential distribution by spacings. Annals of the Institute of Statistical Mathematics, 30, 163–166.
- Epstein, B. (1960). Tests for the validity of the assumption that the underlying distribution of life is exponential. Technometrics, 2, 83–101 and 167–183.
- Frosini, B. V. (1987). On the distribution and power of a goodness-of-fit statistic with parametric and nonparametric applications. In Goodness-of-fit, 133–154.
- Kimber, A. C. (1985). Tests for the exponential, Weibull and Gumbel distributions based on the stabilized probability plot. Biometrika, 72, 661–663.
- Kochar, S. C. (1985). Testing exponentiality against monotone failure rate average. Communications in Statistics: Theory and Methods, 14, 381–392.
- Moran, P. A. P. (1951). The random division of an interval, Part II. JRSS B, 13, 147–150.
- Rossberg, H.-J. (1972). Characterization of the exponential and the Pareto distributions by means of some properties of the distributions which the differences and quotients of order statistics are subject to. Mathematische Operationsforschung und Statistik, 3, 207–216.
- Gail, M. H., & Gastwirth, J. L. (1978). A scale-free goodness-of-fit test for the exponential distribution based on the Gini statistic. JRSS B, 40, 350–357.
- Patwardhan, G. (1988). Tests for exponentiality. Communications in Statistics: Theory and Methods, 17, 3705–3722.
- Shapiro, S. S., & Wilk, M. B. (1972). An analysis of variance test for the exponential distribution (complete samples). Technometrics, 14, 355–370.
- Westfall, P. H., & Young, S. S. (1993). Resampling-based multiple testing. Wiley.
- Klefsjö, B. (1982). On aging properties and total time on test transforms. Scandinavian Journal of Statistics, 9, 37–41.
- Proschan, F., & Pyke, R. (1967). Tests for monotone failure rate. Proceedings of the 5th Berkeley Symposium, 3, 293–312.
From the CodeSplash method registry · life.exponentiality v1.0.2.