Skip to content
svgpit-histogram

PIT histogram

Do the actual values look like draws from the forecast distributions?

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

How to read it

  1. Read each bar as how often actuals fell in that part of their forecast distribution.
  2. Flat means calibrated.
  3. A U means intervals are too narrow, a hump too wide, and a slope means bias.

Watch out

  • A flat histogram is necessary, not sufficient: a forecast can be calibrated and still be uninformative.

Defaults

No settings: the chart draws one way.

Pinned in the code

  • PIT values come from the quantiles the engine reports as interval bounds, with the point forecast as the median, joined linearly (cs-ml backtest.rs). More interval levels make them closer to the true transform.
  • Actuals outside the widest interval count halfway to 0 or 1, since the engines report nothing further out.
  • Bins are equal width over 0–1; the dashed line is the share a calibrated forecast would put in each.
  • Forecasts from the same origin share errors, so bars vary more than independent draws would.
# PIT histogram — Codesplash Chart Lab (recipe "pit-histogram")
# 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("pit-histogram-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")
SHARE = "share"
share = df[SHARE].fillna(0).to_numpy()
edges = np.linspace(0, 1, len(share) + 1)
fig, ax = plt.subplots(figsize=(7, 4))
ax.bar(edges[:-1], share, width=np.diff(edges) * 0.96, align="edge", color=PALETTE[0])
ax.axhline(1 / len(share), color="#6b7280", linestyle="--", label="well calibrated")
ax.set_xlabel("where the actual fell in its forecast distribution")
ax.set_ylabel("share of forecasts")
ax.legend(fontsize=8)
plt.show()

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