Pair probabilities rather than row positions, state the reference distribution and inspect tail behavior separately.
Q–Q plots: compare distribution shape beyond one summary number
A quantile is an ordered position
A Q–Q plot compares quantiles from two distributions at the same cumulative probabilities. It does not pair individual records, even if both samples have the same size. State whether the horizontal axis is an observed reference group or a theoretical distribution, and label units on both axes. ECDF and percentile reading provide the underlying probability view. A line of points near a diagonal suggests broadly similar locations and spreads only if both axes use the same unit and scale; otherwise the reference may have a non-unit slope.
Choose a quantile convention
Software packages differ in how they interpolate between observations. Write down the convention when results will be compared across tools. Repeated values produce repeated or flat stretches; adding random jitter to hide ties changes the apparent pattern. For samples of different sizes, evaluate a common probability grid rather than aligning the first observation of each sorted list. Do not include probability zero or one in a theoretical distribution whose inverse CDF is infinite there. Box and violin views are useful companions when the Q–Q plot is too technical for a general audience.
Read center and tails separately
A nearly straight center with an upward bend in the high tail may indicate more large values in the vertical sample. A shift can move all points above the reference; a scale difference can change the slope. Avoid treating visual departures as an automatic hypothesis test. With a small sample, endpoints are unstable; with a huge sample, slight departures may be practically irrelevant. Sample-size uncertainty belongs in the caption. If the question is about service-level failures, count observations beyond a meaningful threshold as well as inspecting tail curvature.
Keep the comparison reproducible
Filter both samples by the same eligibility and time-window rules, then report their sizes and missing-value counts. If one group contains outages and the other excludes them, the plot is comparing policies as well as distributions. A chart export manifest should include filters, quantile grid, interpolation rule and transformed values. Provide a compact table of selected quantile pairs so a reader can inspect exact numbers without relying on hover or color. Never reverse the axes silently between reports.
Worked contract
from math import isfinite
def interpolate_quantile(sorted_values: list[float], probability: float) -> float:
if not sorted_values or not 0 <= probability <= 1:
raise ValueError("sample and probability are required")
index = (len(sorted_values) - 1) * probability
low = int(index)
high = min(low + 1, len(sorted_values) - 1)
return sorted_values[low] + (index - low) * (sorted_values[high] - sorted_values[low])
def paired_quantiles(reference: list[float], current: list[float],
probabilities: list[float]) -> list[tuple[float, float, float]]:
if not reference or not current or any(not isfinite(value)
for value in reference + current):
raise ValueError("samples must contain finite values")
if any(not 0 <= probability <= 1 for probability in probabilities):
raise ValueError("probabilities must be inside zero and one")
first, second = sorted(reference), sorted(current)
return [(p, interpolate_quantile(first, p), interpolate_quantile(second, p))
for p in probabilities]
quantile_pairs = paired_quantiles([47, 59, 81, 97, 113],
[52, 61, 83, 101, 129], [0.25, 0.5, 0.75])
assert quantile_pairs == [(0.25, 59, 61), (0.5, 81, 83), (0.75, 97, 101)]Performance and operating cost
Sorting reference and current samples of sizes A and B takes O(A log A + B log B) time; Q paired probabilities take O(Q) additional time and output space. The code uses linear interpolation at index (N minus one) times probability. It compares two empirical distributions, not a theoretical normal curve or a significance test. Preserve the method and sample sizes with the plot.
Common Mistakes
- Pairing rows by index instead of pairing equal probabilities.
- Switching interpolation methods between reports without disclosure.
- Jittering ties until they look like genuine tail structure.
- Calling every visible bend a statistically important deviation.
Validation drill
Compare 81 delivery-time records before and after a routing change. Plot common percentiles, report sample counts, and inspect whether the upper tail moved more than the median.
Read next
- Empirical CDFs: read thresholds and tails without choosing bins
- Box and violin charts: compare groups without inventing density
- Uncertainty on charts: show denominators and intervals beside estimates
- Chart exports: carry the data, filters and render contract together
