Skip to content
svgesd-sequence

Generalized ESD sequence

How many outliers does Rosner's generalized ESD test find?

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

How to read it

  1. Read the points left to right as the most extreme values removed one by one.
  2. Compare each with its dashed critical value.
  3. The count of outliers is the last step above the line, even if earlier ones dip.
  1. Callout 1: The most extreme value and its studentized deviation.
  2. Callout 2: The dashed line: critical values.
  3. Callout 3: Red: flagged outliers.

Watch out

  • It assumes normal data apart from the outliers, and the count you allow affects the result.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • Draws the engine's numbers as given (precomputed by the Python or R analysis); the chart computes nothing inferential.
  • The number of outliers is max{i : Rᵢ > λᵢ}, not the count of steps above the line — an earlier step below its λ can still be an outlier (masking).
  • Critical values use Rosner's t-approximation at the engine's α for the declared maximum number of outliers.
# Generalized ESD sequence — Codesplash Chart Lab (recipe "esd-sequence")
# controls: defaults
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

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("esd-sequence-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")
S = "step"
R = "R"
L = "lambda"
VAL = "value"
d = df.dropna(subset=[S, R]).sort_values(S)
above = d.loc[d[R] > d[L], S]
n_out = int(above.max()) if len(above) else 0  # Rosner: max{i : R_i > λ_i}, not a count
fig, ax = plt.subplots(figsize=(8, 4.5))
ax.plot(d[S], d[L], color="#c13e2e", linestyle="--", label="critical λ")
ax.plot(d[S], d[R], color=plt.rcParams["text.color"], marker="o", label="R")
out = d[d[S] <= n_out]
ax.scatter(out[S], out[R], s=50, color="#c13e2e", zorder=3, label=f"outliers: {len(out)}")
if VAL:
    for _, r in d.iterrows():
        ax.annotate(f"{r[VAL]:g}", (r[S], r[R]), xytext=(0, 7), textcoords="offset points", ha="center", fontsize=8, color=REF)
ax.set_xlabel("points removed (step i)")
ax.set_ylabel("R (studentized deviation)")
ax.legend(fontsize=8)
plt.show()

Needs pandas, numpy, matplotlib · reads esd-sequence-demo.csv · app theme from the optional codesplash helper