Skip to content
svgprobability-plot

Probability plot

Do these failures fall on a straight line on this family's probability paper?

Demo data · seed 20261101 · 60 rows · default settings · 640 × 360SVG, lightSVG, darkDemo CSV

How to read it

  1. Read x as time and y as the share of units failed; both axes are stretched so the chosen family plots as a straight line.
  2. Check whether the points follow the line: straight points support that family.
  3. On Weibull paper the slope is the shape: above 1 the failure rate rises, below 1 it falls.
  1. Callout 1: The earliest failures, where a family most often fails to fit.
  2. Callout 2: The fitted line: a straight run of points supports this family.
  3. Callout 3: The latest failures, based on the fewest units.
  4. Callout 4: Time on a log scale for this paper.

Watch out

  • A few points at either end always wander, so judge the middle first and the ends with care.
  • Censored units are not plotted, but they raise the order number of later failures, so do not drop them from the data.

Defaults

Paper
Weibull
The family whose straight line you are checking against.
Also: Log-normal · Exponential · Log-logistic · Normal

Pinned in the code

  • Plotting positions: Benard's median ranks (i − 0.3)/(n + 0.4) with Johnson's adjusted order numbers for censored units; failures come before suspensions at a tie.
  • Without engine rows the line is rank regression of paper y on paper x. With them it is the fitted CDF the engine sent.
  • The plot correlation is Pearson's r of the plotted points.
# Probability plot — Codesplash Chart Lab (recipe "probability-plot")
# controls: paper=weibull
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from scipy import stats

try:
    import codesplash as cs  # optional: the app's chart theme
except ImportError:
    cs = None
if cs:
    cs.use_codesplash(dark=False)
PALETTE = cs.palette(dark=False)["categorical"] if cs else plt.rcParams["axes.prop_cycle"].by_key()["color"]

df = pd.read_csv("probability-plot-demo.csv", keep_default_na=False, na_values=[""])  # demo data (only empty cells are missing): Chart Lab → Code → Download demo CSV

_tokens = cs.palette(dark=False) if cs else {}
SEQ = _tokens.get("sequential", ["#eff6fd", "#1a469d"])  # sequential ramp (low → high)
DIV = _tokens.get("diverging", ["#c13e2e", "#f3f5f8", "#0859ac"])  # negative, midpoint, positive
REF = _tokens.get("reference", "#4e5661")
GREY = _tokens.get("dim", "#ced1d6")
T = "hours"
E = "failed"
F = None
FAM = None
def median_ranks(t, e=None):
    """Johnson's adjusted order numbers with Benard's median ranks; failures before suspensions at a tie."""
    t = np.asarray(t, dtype=float)
    e = np.ones(t.size, dtype=bool) if e is None else np.asarray(e, dtype=float) > 0
    keep = np.isfinite(t) & (t > 0)
    t, e = t[keep], e[keep]
    o = np.lexsort((~e, t))
    t, e = t[o], e[o]
    n, prev, ts, fs = t.size, 0.0, [], []
    for i in range(n):
        if e[i]:
            prev += (n + 1 - prev) / (n - i + 1)
            ts.append(t[i])
            fs.append((prev - 0.3) / (n + 0.4))
    return np.array(ts), np.array(fs)
def paper_x(paper, t):
    return t if paper in ("exponential", "normal") else np.log(t)

def paper_y(paper, f):
    if paper == "weibull":
        return np.log(-np.log1p(-f))
    if paper == "exponential":
        return -np.log1p(-f)
    if paper == "loglogistic":
        return np.log(f / (1 - f))
    return stats.norm.ppf(f)

def paper_line(rows, paper, x):
    """The engine's fitted curve for this family when present, else rank regression of paper y on paper x."""
    if rows is not None and len(rows):
        curve = rows[(rows[F] > 0) & (rows[F] < 1)].sort_values(T)
        return paper_x(paper, curve[T].to_numpy(float)), paper_y(paper, curve[F].to_numpy(float))
    xs, ys = x
    b, a = np.polyfit(xs, ys, 1)
    return np.array([xs.min(), xs.max()]), a + b * np.array([xs.min(), xs.max()])

def split_rows(df):
    is_data = df[FAM].astype(str).str.lower().eq("data") if FAM else pd.Series(True, index=df.index)
    return df[is_data], df[~is_data]
PAPER = "weibull"
sample, curves = split_rows(df)
tt, ff = median_ranks(sample[T], sample[E] if E else None)
xs, ys = paper_x(PAPER, tt), paper_y(PAPER, ff)
fit_rows = curves[curves[FAM].astype(str) == PAPER] if FAM and F else None
lx, ly = paper_line(fit_rows, PAPER, (xs, ys))
fig, ax = plt.subplots(figsize=(7, 4.5))
ax.plot(lx, ly, color=REF, linewidth=1.5)
ax.scatter(xs, ys, s=18, color=PALETTE[0], alpha=0.8)
probs = np.array([0.01, 0.05, 0.1, 0.2, 0.5, 0.8, 0.9, 0.99])
probs = probs[(probs >= ff.min() * 0.9) & (probs <= ff.max() * 1.1)]
ax.set_yticks(paper_y(PAPER, probs), [f"{p:.0%}" for p in probs])
ax.set_xlabel(T if PAPER in ("exponential", "normal") else f"log {T}")
ax.set_ylabel("Cumulative failure probability")
ax.set_title(f"{PAPER} probability plot: plot correlation {np.corrcoef(xs, ys)[0, 1]:.3f}", fontsize=10, loc="left")
plt.show()

Needs pandas, numpy, matplotlib, scipy · reads probability-plot-demo.csv · app theme from the optional codesplash helper