Mathematical Simplicity
Building and checking models
Principle or heuristic
Advanced
Not always the same as conceptual simplicity.
What it is
Gelman’s golf-putting example makes the point. The mathematically simple model for probability of success against distance is a logistic regression with two parameters and a standard link function. The conceptually simple model starts from geometry: the putt succeeds if the angle of the shot is within the angular size of the hole, and angle errors are normal. That model needs trigonometry, but it has one parameter with a physical meaning, and it fits better and extrapolates sensibly.
Why it matters
Analysts often reach for the model that is easiest to write in standard software and call it “simple.” But a model that follows the actual mechanism can be simpler to understand, with fewer arbitrary parameters, more interpretable estimates and better behavior outside the data. Keeping the trig is choosing conceptual simplicity over mathematical convenience.
How it works
With hole radius \(R\), ball radius \(r\) and angular error sd \(\sigma\), a putt from distance \(x\) succeeds if \(|\text{angle}| < \arcsin\big((R - r)/x\big)\), so
\[ \Pr(\text{success} \mid x) = 2\,\Phi\!\left(\frac{\arcsin\big((R-r)/x\big)}{\sigma}\right) - 1. \]
The model has one parameter, \(\sigma\), a golfer’s angular precision. The logistic model \(\text{logit}^{-1}(a + bx)\) has two parameters with no physical meaning, and its shape is wrong at short and long distances.
Simulated example
Putting data are simulated from the geometric model, with distances from 2 to 20 feet. Both models are fit, then extended to 40 feet.
Show simulation code
The R version uses base R, and the Python version uses NumPy and Matplotlib. Where the simulation draws random numbers, each language draws its own, so exact numbers differ slightly but show the same pattern. The numbered markers in the R code are explained under it.
import {rng, range, invLogit, pnorm, sum, fmt} from "../js/stats.js"
viewof sigmaDeg = Inputs.range([0.5, 3], {value: 1.5, step: 0.1, label: "True angular error σ (degrees)"})
viewof nPer = Inputs.range([20, 1000], {value: 200, step: 20, label: "Putts per distance"})
viewof seed = Inputs.range([1, 500], {value: 90, step: 1, label: "Random seed"})
golf = {
const r = rng(seed);
const R = 4.25 / 2 / 12, rb = 1.68 / 2 / 12;
const geo = (x, s) => 2 * pnorm(Math.asin(Math.min(1, (R - rb) / x)) / s) - 1;
const sTrue = sigmaDeg * Math.PI / 180;
const data = range(19).map(i => { const x = 2 + i; return {x, n: nPer, y: r.binomial(nPer, geo(x, sTrue))}; });
// Geometry fit: grid search on sigma.
let bestS = 0.01, bestLL = -Infinity;
for (let s = 0.002; s < 0.08; s += 0.0002) {
const ll = sum(data.map(d => { const p = Math.min(1 - 1e-9, Math.max(1e-9, geo(d.x, s))); return d.y * Math.log(p) + (d.n - d.y) * Math.log(1 - p); }));
if (ll > bestLL) { bestLL = ll; bestS = s; }
}
// Logistic fit: Newton on aggregated binomial.
let a = 0, b = 0;
for (let it = 0; it < 50; it++) {
let ga = 0, gb = 0, haa = 0, hab = 0, hbb = 0;
for (const d of data) { const p = invLogit(a + b * d.x), w = d.n * p * (1 - p); ga += d.y - d.n * p; gb += (d.y - d.n * p) * d.x; haa -= w; hab -= w * d.x; hbb -= w * d.x * d.x; }
const det = haa * hbb - hab * hab; a -= (hbb * ga - hab * gb) / det; b -= (haa * gb - hab * ga) / det;
}
const curves = range(77).map(i => 2 + i * 0.5).flatMap(x => [
{x, model: "Geometry (1 parameter)", p: geo(x, bestS)},
{x, model: "Logistic (2 parameters)", p: invLogit(a + b * x)},
{x, model: "Truth", p: geo(x, sTrue)}
]);
return {data, curves, bestS, a, b};
}
Plot.plot({
ariaLabel: "Mathematical Simplicity: simulation chart",
ariaDescription: "Horizontal axis: Distance (feet). Vertical axis: Probability of success. The chart updates with the controls above it, and the summary below the charts states the result in words.",
height: 320,
x: {label: "Distance (feet)", grid: true},
y: {label: "Probability of success", domain: [0, 1], grid: true},
color: {legend: true, domain: ["Geometry (1 parameter)", "Logistic (2 parameters)", "Truth"], range: ["#2166ac", "#d6604d", "#8a8a8a"]},
marks: [
Plot.rect([0], {x1: 20, x2: 40, y1: 0, y2: 1, fill: "#8a8a8a", fillOpacity: 0.07}),
Plot.line(golf.curves, {x: "x", y: "p", stroke: "model", strokeWidth: 2, strokeDasharray: d => d.model === "Truth" ? "4 3" : null}),
Plot.dot(golf.data, {x: "x", y: d => d.y / d.n, fill: "currentColor", r: 3}),
Plot.text([0], {x: 30, y: 0.95, text: () => "extrapolation"})
]
})# Mathematical Simplicity: the golf-putting geometry model vs a logistic fit.
1sigma_deg <- 1.5 # true angular error (degrees)
n_per <- 200 # putts per distance
2set.seed(90)
r_hole <- 4.25 / 2 / 12
r_ball <- 1.68 / 2 / 12 # radii, in feet
3p_geo <- function(x, sigma) 2 * pnorm(asin((r_hole - r_ball) / x) / sigma) - 1
sigma_true <- sigma_deg * pi / 180
x <- 2:20
n <- rep(n_per, length(x))
y <- rbinom(length(x), n, p_geo(x, sigma_true))
# Geometric model: one parameter, fitted by maximum likelihood
nll <- function(s) -sum(dbinom(y, n, p_geo(x, s), log = TRUE))
4sigma_hat <- optimize(nll, c(0.005, 0.1))$minimum
# Logistic regression: two parameters
5fit <- glm(cbind(y, n - y) ~ x, family = binomial)
cat("Geometric model: sigma = ", round(sigma_hat * 180 / pi, 2),
" degrees (truth: ", sigma_deg, ")\n",
sep = ""
)
6at40 <- c(
truth = p_geo(40, sigma_true), geometry = p_geo(40, sigma_hat),
logistic = unname(predict(fit, data.frame(x = 40),
type = "response"
))
)
print(round(at40, 3)) # success probability at 40 feet
grid <- seq(2, 40, by = 0.5)
7plot(x, y / n,
pch = 19, xlim = c(2, 40), ylim = c(0, 1),
xlab = "Distance (feet)", ylab = "Probability of success"
)
rect(20, -1, 42, 2, col = adjustcolor("grey", 0.2), border = NA)
lines(grid, p_geo(grid, sigma_true), lty = 2, col = "grey40")
lines(grid, p_geo(grid, sigma_hat), col = "#2166ac", lwd = 2)
lines(grid, predict(fit, data.frame(x = grid), type = "response"),
col = "#d6604d", lwd = 2
)
legend("topright", c(
"Geometry (1 parameter)", "Logistic (2 parameters)",
"Truth"
),
col = c("#2166ac", "#d6604d", "grey40"),
lty = c(1, 1, 2), lwd = c(2, 2, 1), bty = "n"
)- 1
- The page’s controls: the golfer’s true angular error and the number of putts per distance.
- 2
- Fixes the random numbers so the run is reproducible.
- 3
- The geometry model: a putt goes in if its angle is within the window set by the hole’s and the ball’s radii. One parameter, derived from first principles.
- 4
- That parameter fitted by maximum likelihood.
- 5
- The competitor: a logistic regression with two parameters and no geometry.
- 6
- Both models’ predictions at 40 feet, outside the data. The geometric model extrapolates sensibly; the logistic one does not.
- 7
- The data, both fits and the truth, with the extrapolation region shaded.
# Mathematical Simplicity: the golf-putting geometry model vs a logistic fit.
from statistics import NormalDist
import numpy as np
import matplotlib.pyplot as plt
sigma_deg = 1.5 # true angular error (degrees)
n_per = 200 # putts per distance
rng = np.random.default_rng(90)
R_hole, r_ball = 4.25 / 2 / 12, 1.68 / 2 / 12 # radii, in feet
cdf = np.vectorize(NormalDist().cdf)
def p_geo(x, sigma):
return 2 * cdf(np.arcsin((R_hole - r_ball) / x) / sigma) - 1
sigma_true = sigma_deg * np.pi / 180
x = np.arange(2, 21)
y = rng.binomial(n_per, p_geo(x, sigma_true))
# Geometric model: one parameter, by maximum likelihood on a grid
grid_s = np.arange(0.002, 0.08, 0.0002)
loglik = [np.sum(y * np.log(np.clip(p_geo(x, s), 1e-9, 1 - 1e-9))
+ (n_per - y) * np.log(np.clip(1 - p_geo(x, s), 1e-9, 1)))
for s in grid_s]
sigma_hat = grid_s[np.argmax(loglik)]
# Logistic regression: two parameters, by Newton's method
beta = np.zeros(2)
X = np.column_stack([np.ones_like(x), x])
for _ in range(50):
p = 1 / (1 + np.exp(-X @ beta))
W = n_per * p * (1 - p)
beta += np.linalg.solve(X.T @ (W[:, None] * X), X.T @ (y - n_per * p))
def p_logit(d):
return 1 / (1 + np.exp(-(beta[0] + beta[1] * d)))
print(f"Geometric model: sigma = {np.degrees(sigma_hat):.2f} degrees "
f"(truth: {sigma_deg})")
print(f"At 40 feet: truth {p_geo(40, sigma_true):.3f}, geometry "
f"{p_geo(40, sigma_hat):.3f}, logistic {p_logit(40):.3f}")
grid = np.arange(2, 40.01, 0.5)
plt.axvspan(20, 40, color="0.9")
plt.plot(x, y / n_per, "o", color="black")
plt.plot(grid, p_geo(grid, sigma_true), "--", color="0.4", label="Truth")
plt.plot(grid, p_geo(grid, sigma_hat), color="#2166ac", linewidth=2,
label="Geometry (1 parameter)")
plt.plot(grid, p_logit(grid), color="#d6604d", linewidth=2,
label="Logistic (2 parameters)")
plt.ylim(0, 1)
plt.xlabel("Distance (feet)")
plt.ylabel("Probability of success")
plt.legend()
plt.show()Try it in R. This simulation is also written in R. You can edit it and run it in your browser with webR, with nothing to install.
Key takeaways
- A standard functional form isn’t necessarily the simplest model.
- Models built from the mechanism have fewer, more meaningful parameters.
- Mechanistic models often extrapolate far better than generic curves.
Source
- Andrew Gelman, Why we kept the trig in golf (2020).
- Andrew Gelman, Model building and expansion for golf putting (Stan case study, 2019).