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.
What runs in CodeSplash
- STAT128Cox–Oakes exponentiality test Runs in CodeSplash
- STAT129Epps–Pulley exponentiality test Runs in CodeSplash
- STAT130Henze–Meintanis exponentiality tests Runs in CodeSplash
- STAT131Meintanis–Iliopoulos exponentiality tests Runs in CodeSplash
- STAT132Gnedenko exponentiality F test Runs in CodeSplash
- STAT133Harris exponentiality test Runs in CodeSplash
- STAT134Hegazy–Green tests Runs in CodeSplash
- STAT135Hollander–Proschan exponentiality test Runs in CodeSplash
- STAT136Deshpande exponentiality test Runs in CodeSplash
- STAT137Atkinson exponentiality test Runs in CodeSplash
- STAT138Ahsanullah exponentiality test Runs in CodeSplash
- STAT139Epstein exponentiality test Runs in CodeSplash
- STAT140Frozini exponentiality test Runs in CodeSplash
- STAT141Kimber–Michael exponentiality test Runs in CodeSplash
- STAT142Kochar exponentiality test Runs in CodeSplash
- STAT143Moran exponentiality test Runs in CodeSplash
- STAT144Rossberg exponentiality test Runs in CodeSplash
- STAT145Gini exponentiality test Runs in CodeSplash
- STAT146Patwardhan exponentiality test Runs in CodeSplash
- Exponentiality tests (battery) Verified in Python and R
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
Thirty tests, truly exponential data
PredictPredict 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: . Here 2 of 30 rejected. Rejections on a battery aren't votes, and these are false alarms.
Families
ReadThe tests differ in what they look at.
| Family | Tests | Looks at |
|---|---|---|
| Spacings | Gnedenko, Harris, Epstein, Patwardhan | Gaps between sorted lifetimes |
| Transforms | Epps–Pulley, Henze–Meintanis, Meintanis–Iliopoulos | Transforms of the data |
| Probability plot | Hegazy–Green, Frozini, Kimber–Michael | Sorted values against exponential quantiles |
| Hazard shape | Cox–Oakes, Moran, Atkinson, Gini, Kochar | Scale-free summaries |
| Characterizations | Hollander–Proschan, Deshpande, Ahsanullah, Rossberg | Properties only an exponential has |
Moran's test here has nothing to do with spatial Moran's I.
Spacings
ReadSort the lifetimes. Multiply each gap by the number of units still running:
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.
Why simulation works
ReflectMost 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 , or one-sided.
How many simulated samples would you ask for on a final report, compared with a first look? Why?
Wear-out and bearings
ReadOn simulated wear-out data every test agrees: 30 of 30 reject.
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
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 |
View data
| Series | Fitted 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 |
| exponential | 0.2193 | 17.880 |
| exponential | 0.2473 | 20.516 |
| exponential | 0.2743 | 23.152 |
| exponential | 0.3003 | 25.788 |
| exponential | 0.3254 | 28.424 |
| exponential | 0.3495 | 31.060 |
| exponential | 0.3728 | 33.696 |
| exponential | 0.3953 | 36.332 |
| exponential | 0.4170 | 38.967 |
| exponential | 0.4379 | 41.603 |
| exponential | 0.4580 | 44.239 |
| exponential | 0.4775 | 46.875 |
| exponential | 0.4962 | 49.511 |
| exponential | 0.5142 | 52.147 |
| exponential | 0.5317 | 54.783 |
| exponential | 0.5484 | 57.419 |
| exponential | 0.5646 | 60.055 |
| exponential | 0.5802 | 62.691 |
| exponential | 0.5953 | 65.327 |
| exponential | 0.6098 | 67.963 |
| exponential | 0.6238 | 70.599 |
| exponential | 0.6372 | 73.235 |
| exponential | 0.6502 | 75.871 |
| exponential | 0.6628 | 78.506 |
| exponential | 0.6749 | 81.142 |
| exponential | 0.6865 | 83.778 |
| exponential | 0.6978 | 86.414 |
| exponential | 0.7086 | 89.050 |
| exponential | 0.7190 | 91.686 |
| exponential | 0.7291 | 94.322 |
| exponential | 0.7388 | 96.958 |
| exponential | 0.7482 | 99.594 |
| exponential | 0.7572 | 102.23 |
| exponential | 0.7659 | 104.87 |
| exponential | 0.7743 | 107.50 |
| exponential | 0.7824 | 110.14 |
| exponential | 0.7902 | 112.77 |
First 60 of 83 rows.
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
| Test | Statistic | z | p (reference) | p (simulated) | p used | p adjusted | Rejects at .05 |
|---|---|---|---|---|---|---|---|
| Cox–Oakes | 17.212 | 2.798 | .005 | — | .005 | — | yes |
| Epps–Pulley | 0.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 F | 2.371 | — | .042 | — | .042 | — | yes |
| Harris | 2.345 | — | .042 | — | .042 | — | yes |
| Hegazy–Green T₁ | 0.2643 | — | — | .050 | .050 | — | no |
| Hegazy–Green T₂ | 0.1045 | — | — | .270 | .270 | — | no |
| Hollander–Proschan | 0.1276 | −5.456 | < .001 | — | < .001 | — | yes |
| Deshpande | 0.8498 | 4.987 | < .001 | — | < .001 | — | yes |
| Atkinson | 0.0144 | 2.684 | .007 | — | .007 | — | yes |
| Ahsanullah | 0.4764 | 6.174 | < .001 | — | < .001 | — | yes |
| Epstein (Bartlett) | — | — | — | — | — | — | not computed |
| Frosini | 0.5880 | — | — | .005 | .005 | — | yes |
| Kimber–Michael | 0.2252 | — | — | .005 | .005 | — | yes |
| Kochar | 3.393 | 3.393 | < .001 | — | < .001 | — | yes |
| Moran | 0.4479 | 2.675 | .007 | — | .007 | — | yes |
| Rossberg | 0.2507 | 5.593 | < .001 | — | < .001 | — | yes |
| Gini | 0.2887 | −3.433 | < .001 | — | < .001 | — | yes |
| Patwardhan | 64.859 | — | — | .040 | .040 | — | yes |
| Baringhaus–Henze | 0.8071 | — | — | .005 | .005 | — | yes |
| Shapiro–Wilk W for exponentiality | 0.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.7113 | 3.433 | < .001 | — | < .001 | — | yes |
| Proschan–Pyke | 169 | 2.245 | .025 | — | .025 | — | yes |
Mean life under the exponential model
| Mean life | 95% CI low | 95% CI high | Failure rate |
|---|---|---|---|
| 72.221 | 49.870 | 113.93 | 0.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
))
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
| Test | Statistic | z | p (reference) | p (simulated) | p used | p adjusted | Rejects at .05 |
|---|---|---|---|---|---|---|---|
| Cox–Oakes | 17.212 | 2.798 | .005 | — | .005 | .149 | yes |
| Epps–Pulley | 0.4107 | −2.967 | .003 | — | .003 | .087 | yes |
| Henze–Meintanis (exponential weight) | 1.908 | — | — | .005 | .005 | .145 | yes |
| Henze–Meintanis (Gaussian weight) | 0.7354 | — | — | .005 | .005 | .145 | yes |
| Meintanis–Iliopoulos (exponential weight) | 5.619 | — | — | .005 | .005 | .145 | yes |
| Meintanis–Iliopoulos (Gaussian weight) | 0.8727 | — | — | .005 | .005 | .145 | yes |
| Gnedenko F | 2.371 | — | .042 | — | .042 | 1.000 | yes |
| Harris | 2.345 | — | .042 | — | .042 | 1.000 | yes |
| Hegazy–Green T₁ | 0.2643 | — | — | .050 | .050 | 1.000 | no |
| Hegazy–Green T₂ | 0.1045 | — | — | .270 | .270 | 1.000 | no |
| Hollander–Proschan | 0.1276 | −5.456 | < .001 | — | < .001 | < .001 | yes |
| Deshpande | 0.8498 | 4.987 | < .001 | — | < .001 | < .001 | yes |
| Atkinson | 0.0144 | 2.684 | .007 | — | .007 | .211 | yes |
| Ahsanullah | 0.4764 | 6.174 | < .001 | — | < .001 | < .001 | yes |
| Epstein (Bartlett) | — | — | — | — | — | — | not computed |
| Frosini | 0.5880 | — | — | .005 | .005 | .145 | yes |
| Kimber–Michael | 0.2252 | — | — | .005 | .005 | .145 | yes |
| Kochar | 3.393 | 3.393 | < .001 | — | < .001 | .020 | yes |
| Moran | 0.4479 | 2.675 | .007 | — | .007 | .217 | yes |
| Rossberg | 0.2507 | 5.593 | < .001 | — | < .001 | < .001 | yes |
| Gini | 0.2887 | −3.433 | < .001 | — | < .001 | .017 | yes |
| Patwardhan | 64.859 | — | — | .040 | .040 | 1.000 | yes |
| Baringhaus–Henze | 0.8071 | — | — | .005 | .005 | .145 | yes |
| Shapiro–Wilk W for exponentiality | 0.0998 | — | — | .030 | .030 | .870 | yes |
| Lilliefors (Kolmogorov–Smirnov, rate estimated) | 0.3068 | — | — | .005 | .005 | .145 | yes |
| Anderson–Darling (rate estimated) | 2.811 | — | — | .005 | .005 | .145 | yes |
| Cramér–von Mises (rate estimated) | 0.5360 | — | — | .005 | .005 | .145 | yes |
| Watson U² (rate estimated) | 0.3526 | — | — | .005 | .005 | .145 | yes |
| Total time on test (area under the TTT plot) | 0.7113 | 3.433 | < .001 | — | < .001 | .017 | yes |
| Proschan–Pyke | 169 | 2.245 | .025 | — | .025 | .718 | yes |
Mean life under the exponential model
| Mean life | 95% CI low | 95% CI high | Failure rate |
|---|---|---|---|
| 72.221 | 49.870 | 113.93 | 0.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.
When nothing rejects
PredictPredict first
Air-conditioner failure intervals give 0 rejections of 29.
These intervals are pooled from two aircraft. What can you say?
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.
Commit before you look
ReadThe 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.
Check your understanding
CheckpointCheck 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
. Tests in a battery are correlated, so the count varies more than it would for independent tests, but its expected value is the same.
Do it in CodeSplash
In the appChoose 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.
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)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)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