Skip to content

Thirty tests of one question

How the nineteen exponentiality tests of the guide and their relatives group into families, and how to read the battery without shopping for a p-value.

Advanced ~15 min10 steps

What runs in CodeSplash

You will be able to

  • Group exponentiality tests by the feature of the data they use
  • Explain why simulation gives valid p-values whatever the rate is
  • Read a battery's rejection count without treating it as evidence by votes

Read first

01

Thirty tests, truly exponential data

Predict

Predict first

You run 30 exponentiality tests at the 0.05 level on data simulated from an exponential distribution.

How many tests do you expect to reject?

Make your guess between 0 and 30 tests, then reveal.

Reveal

About one or two: 30×0.05=1.530 \times 0.05 = 1.5. Here 2 of 30 rejected. Rejections on a battery aren't votes, and these are false alarms.

02

Families

Read

The tests differ in what they look at.

FamilyTestsLooks at
SpacingsGnedenko, Harris, Epstein, PatwardhanGaps between sorted lifetimes
TransformsEpps–Pulley, Henze–Meintanis, Meintanis–IliopoulosTransforms of the data
Probability plotHegazy–Green, Frozini, Kimber–MichaelSorted values against exponential quantiles
Hazard shapeCox–Oakes, Moran, Atkinson, Gini, KocharScale-free summaries
CharacterizationsHollander–Proschan, Deshpande, Ahsanullah, RossbergProperties only an exponential has

Moran's test here has nothing to do with spatial Moran's I.

03

Spacings

Read

Sort the lifetimes. Multiply each gap by the number of units still running:

Di=(n−i+1)(X(i)−X(i−1))D_i = (n - i + 1)\left(X_{(i)} - X_{(i-1)}\right)

For exponential lifetimes, these normalized spacingsNormalized spacingsGaps between ordered lifetimes multiplied by the number still running. For exponential data they are independent with the same mean. are independent and all have the same mean. Wear-out breaks that, because later gaps shrink.

Gnedenko's F compares early gaps with late ones. Harris compares both ends with the middle. Choosing the split after seeing the data makes those p-values wrong.

04

Why simulation works

Reflect

Most statistics first divide each lifetime by the sample mean, so the unknown rate cancels out. Their null distribution then doesn't depend on the rate at all.

That means you can simulate from any exponential and get a valid p-value. The cost is granularity: with 199 simulated samples, the smallest two-sided p is 2/200=0.012/200 = 0.01, or 0.0050.005 one-sided.

How many simulated samples would you ask for on a final report, compared with a first look? Why?

05

Wear-out and bearings

Read

On simulated wear-out data every test agrees: 30 of 30 reject.

Exponentiality testsRecorded · Python and R agreeRecorded 2026-11-17 · 230 values compared · largest relative difference 1.8e-10
R

Cox–Oakes = 17.21, p = .005

Mean life
72.221
Failure rate
0.0138
Tests rejecting
27
p, adjusted for the battery
< .001
Tests run
29

Plots

Scaled total-time-on-test plot: revsIs the failure rate rising, falling, constant or bathtub-shaped?
View data
revs
17.880
28.920
33
41.520
42.120
45.600
48.400
51.840
51.960
54.120
55.560
67.800
68.640
68.640
68.880
84.120
93.120
98.640
105.12
105.84
127.92
128.04
173.40
Exponential probability plot: revsDo these failures fall on a straight line on this family's probability paper?
View data
SeriesFitted F(t)revs
data—17.880
data—28.920
data—33
data—41.520
data—42.120
data—45.600
data—48.400
data—51.840
data—51.960
data—54.120
data—55.560
data—67.800
data—68.640
data—68.640
data—68.880
data—84.120
data—93.120
data—98.640
data—105.12
data—105.84
data—127.92
data—128.04
data—173.40
exponential0.219317.880
exponential0.247320.516
exponential0.274323.152
exponential0.300325.788
exponential0.325428.424
exponential0.349531.060
exponential0.372833.696
exponential0.395336.332
exponential0.417038.967
exponential0.437941.603
exponential0.458044.239
exponential0.477546.875
exponential0.496249.511
exponential0.514252.147
exponential0.531754.783
exponential0.548457.419
exponential0.564660.055
exponential0.580262.691
exponential0.595365.327
exponential0.609867.963
exponential0.623870.599
exponential0.637273.235
exponential0.650275.871
exponential0.662878.506
exponential0.674981.142
exponential0.686583.778
exponential0.697886.414
exponential0.708689.050
exponential0.719091.686
exponential0.729194.322
exponential0.738896.958
exponential0.748299.594
exponential0.7572102.23
exponential0.7659104.87
exponential0.7743107.50
exponential0.7824110.14
exponential0.7902112.77

First 60 of 83 rows.

Lorenz curve: revsHow unevenly is the total lifetime shared out among units?
View data
revs
17.880
28.920
33
41.520
42.120
45.600
48.400
51.840
51.960
54.120
55.560
67.800
68.640
68.640
68.880
84.120
93.120
98.640
105.12
105.84
127.92
128.04
173.40

Assumptions

  • Independent lifetimes — Not testable from these numbers alone; check how the units were sampled.
  • Complete lifetimes — All 23 values are treated as failures. For censored units use Distribution ID.
  • No tied lifetimes — 1 tied value(s): zero spacings stop the Epstein test and weaken the other spacing tests.

Exponentiality tests

TestStatisticzp (reference)p (simulated)p usedp adjustedRejects at .05
Cox–Oakes17.2122.798.005—.005—yes
Epps–Pulley0.4107−2.967.003—.003—yes
Henze–Meintanis (exponential weight)1.908——.005.005—yes
Henze–Meintanis (Gaussian weight)0.7354——.005.005—yes
Meintanis–Iliopoulos (exponential weight)5.619——.005.005—yes
Meintanis–Iliopoulos (Gaussian weight)0.8727——.005.005—yes
Gnedenko F2.371—.042—.042—yes
Harris2.345—.042—.042—yes
Hegazy–Green T₁0.2643——.050.050—no
Hegazy–Green T₂0.1045——.270.270—no
Hollander–Proschan0.1276−5.456< .001—< .001—yes
Deshpande0.84984.987< .001—< .001—yes
Atkinson0.01442.684.007—.007—yes
Ahsanullah0.47646.174< .001—< .001—yes
Epstein (Bartlett)——————not computed
Frosini0.5880——.005.005—yes
Kimber–Michael0.2252——.005.005—yes
Kochar3.3933.393< .001—< .001—yes
Moran0.44792.675.007—.007—yes
Rossberg0.25075.593< .001—< .001—yes
Gini0.2887−3.433< .001—< .001—yes
Patwardhan64.859——.040.040—yes
Baringhaus–Henze0.8071——.005.005—yes
Shapiro–Wilk W for exponentiality0.0998——.030.030—yes
Lilliefors (Kolmogorov–Smirnov, rate estimated)0.3068——.005.005—yes
Anderson–Darling (rate estimated)2.811——.005.005—yes
Cramér–von Mises (rate estimated)0.5360——.005.005—yes
Watson U² (rate estimated)0.3526——.005.005—yes
Total time on test (area under the TTT plot)0.71133.433< .001—< .001—yes
Proschan–Pyke1692.245.025—.025—yes

Mean life under the exponential model

Mean life95% CI low95% CI highFailure rate
72.22149.870113.930.0138
  • 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.
  • 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. 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.
The exact R script · R 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 2eae373764d3e143
# Dataset: life_bearings (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_bearings.parquet", col_select = c("revs")))
n_input <- nrow(df)
df <- df[stats::complete.cases(df[c("revs")]), , 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("revs"))  # infinite values stop the run (registry/errors.yaml)

# %% Tests
y <- "revs"
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 = "reference", 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
))
Python

Cox–Oakes = 17.21, p = .005

Mean life
72.221
Failure rate
0.0138
Tests rejecting
27
p, adjusted for the battery
< .001
Tests run
29

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 23 values are treated as failures. For censored units use Distribution ID.
  • No tied lifetimes — 1 tied value(s): zero spacings stop the Epstein test and weaken the other spacing tests.

Exponentiality tests

TestStatisticzp (reference)p (simulated)p usedp adjustedRejects at .05
Cox–Oakes17.2122.798.005—.005.149yes
Epps–Pulley0.4107−2.967.003—.003.087yes
Henze–Meintanis (exponential weight)1.908——.005.005.145yes
Henze–Meintanis (Gaussian weight)0.7354——.005.005.145yes
Meintanis–Iliopoulos (exponential weight)5.619——.005.005.145yes
Meintanis–Iliopoulos (Gaussian weight)0.8727——.005.005.145yes
Gnedenko F2.371—.042—.0421.000yes
Harris2.345—.042—.0421.000yes
Hegazy–Green T₁0.2643——.050.0501.000no
Hegazy–Green T₂0.1045——.270.2701.000no
Hollander–Proschan0.1276−5.456< .001—< .001< .001yes
Deshpande0.84984.987< .001—< .001< .001yes
Atkinson0.01442.684.007—.007.211yes
Ahsanullah0.47646.174< .001—< .001< .001yes
Epstein (Bartlett)——————not computed
Frosini0.5880——.005.005.145yes
Kimber–Michael0.2252——.005.005.145yes
Kochar3.3933.393< .001—< .001.020yes
Moran0.44792.675.007—.007.217yes
Rossberg0.25075.593< .001—< .001< .001yes
Gini0.2887−3.433< .001—< .001.017yes
Patwardhan64.859——.040.0401.000yes
Baringhaus–Henze0.8071——.005.005.145yes
Shapiro–Wilk W for exponentiality0.0998——.030.030.870yes
Lilliefors (Kolmogorov–Smirnov, rate estimated)0.3068——.005.005.145yes
Anderson–Darling (rate estimated)2.811——.005.005.145yes
Cramér–von Mises (rate estimated)0.5360——.005.005.145yes
Watson U² (rate estimated)0.3526——.005.005.145yes
Total time on test (area under the TTT plot)0.71133.433< .001—< .001.017yes
Proschan–Pyke1692.245.025—.025.718yes

Mean life under the exponential model

Mean life95% CI low95% CI highFailure rate
72.22149.870113.930.0138
  • 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.
  • 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. 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.
The exact Python script · Python 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 2eae373764d3e143
# Dataset: life_bearings (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_bearings.parquet", columns=["revs"])
n_input = len(df)
df = df.dropna(subset=["revs"])  # 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, ["revs"])  # infinite values stop the run (registry/errors.yaml)

# %% Tests
y = "revs"
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="reference", 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 ball bearings give 27 of 29, and 1 test was not computed.

That one is Epstein: two bearings have the same recorded life, so a spacing is zero and its logarithm is undefined. The battery says so rather than adding a constant.

06

When nothing rejects

Predict

Predict first

Air-conditioner failure intervals give 0 rejections of 29.

These intervals are pooled from two aircraft. What can you say?

They are exponentialThey are compatible with exponential, and that is all
Reveal

Compatible, and that is all. There are only 36 intervals, the tests are correlated, and pooling units with different rates gives a falling hazard that small samples can't see. Thirty tests aren't thirty independent checks.

07

Commit before you look

Read

The card gives a lead test, Cox–Oakes, and a p-value adjusted for running all the tests. On the simulated exponential data 2 tests rejected, but the adjusted p is p = .220 and the lead test gives p = .720. So the card reads "that is what chance gives across this many overlapping tests, so the lifetimes are compatible with a constant failure rate".

If you expect wear-out, decide before you look which test you would trust, and run it alone under Test. With thirty p-values, the temptation is to quote the smallest. Report your chosen test, the adjusted p, the count and the plot.

08

Check your understanding

Checkpoint

Check yourself

Why can a simulated p-value from an exponential with rate 1 be used for lifetimes with any rate?

Show the answer

Answer: a

Scale-free statistics have the same null distribution for every rate. The exponential assumption is what's being tested, and it's still there in the null.

Check yourself

Epstein's test reports "not computed" on your data. What is the most likely reason?

Show the answer

Answer: b

Rounded lifetimes often tie. The test uses logs of the spacings, so a zero can't be handled, and adding a small constant would change the test without saying so.

Check yourself

You run 20 independent tests at the 0.05 level on data for which every null is true. How many false rejections do you expect?

Show the answer

Answer: 1

20×0.05=120 \times 0.05 = 1. Tests in a battery are correlated, so the count varies more than it would for independent tests, but its expected value is the same.

09

Do it in CodeSplash

In the app

Choose the battery or a single test under Test, and raise Simulated samples for a final result. In Studios, Quality & DoE has the same battery as a step in its life-data flow.

This script computes three of the statistics from the guide's formulas: Cox–Oakes, Moran and Epstein. They match −2.174, −0.0402 and 36.00.

Python
import numpy as np
import pandas as pd

x = np.sort(pd.read_csv("life_exp_sim.csv")["x"].to_numpy())
n, y = len(x), x / x.mean()

cox_oakes = n + np.sum((1 - y) * np.log(y))
moran = np.euler_gamma + np.mean(np.log(y))

d = (n - np.arange(n)) * np.diff(np.r_[0, x])
epstein = 2 * n * (np.log(d.mean()) - np.mean(np.log(d))) / (1 + (n + 1) / (6 * n))
print(cox_oakes, moran, epstein)
R
x <- sort(read.csv("life_exp_sim.csv")$x)
n <- length(x); y <- x / mean(x)

cox_oakes <- n + sum((1 - y) * log(y))
moran <- -digamma(1) + mean(log(y))

d <- (n - 0:(n - 1)) * diff(c(0, x))
epstein <- 2 * n * (log(mean(d)) - mean(log(d))) / (1 + (n + 1) / (6 * n))
c(cox_oakes, moran, epstein)
10

Recap

Recap
  • Exponentiality tests fall into families: spacings, transforms, probability plots, hazard shape and characterizations.
  • Scale-free statistics allow valid simulated p-values for any rate.
  • Rejections in a battery aren't votes. Name a lead test first, judge the battery by its adjusted p, and report the count and the plot.
  • No rejection is compatible with a constant rate; it doesn't show one.

Concepts in this lesson