Skip to content

Golf putting ​

Estimate an angular error scale from putting counts, then compare replicated success proportions with the observations. The example uses the public putting data discussed in the Stan case study, which attributes the observations to Berry's study of professional golf. Each row records distance in feet, the number of attempts and the number made. These are aggregated counts, not trajectories of individual balls. The source file contains the observations explicitly; no private records or external download are required to reproduce the calculation.

DistancesAttemptsSuccessful puttsDistance range (ft)
19598833902.0–20.0

Geometry ​

A putt succeeds when its direction falls within an angular tolerance set by the distance and the clearance between ball and hole. The model treats angular error as a centered normal variable. It assumes the ball travels far enough, that the green introduces no additional directional variation, and that putts at a given distance share one success probability. Those assumptions define what the fitted error scale measures. They do not identify separate sources of error such as player variation, slope or speed control.

The clearance is half the difference between hole and ball diameters, converted to feet. Dividing that clearance by distance gives the sine of the limiting angle. The probability that a centered normal angular error falls between the negative and positive limit is therefore a difference of normal distribution functions. The model evaluates that probability for every observed distance and uses the attempt counts in a binomial likelihood.

Angular standard deviation is positive. Its prior is a normal distribution restricted to that support; the standard deviation of the prior is expressed in radians. The derived degree scale changes only the presentation. It does not change the density or introduce another parameter. The following source is the file executed by this build. Its generated Stan program is compiled with the Stan compiler before being included on the page.

julia
using StanBlocks

# Distance and ball/cup clearance are in feet; counts are from Berry (1996).
golf_data = (;
    distance = Float64.(2:20),
    attempts = [1443, 694, 455, 353, 272, 256, 240, 217, 200, 237,
                202, 192, 174, 167, 201, 195, 191, 147, 152],
    sunk = [1346, 577, 337, 208, 149, 136, 111, 69, 67, 75,
            52, 46, 54, 28, 27, 31, 33, 20, 24],
    gap = (4.25 - 1.68) / 24,
)

const angle_error = @slic begin
    sigma ~ normal(0, 0.1; lower=0)
    tolerance = asin(gap ./ distance)
    p = 2 * Phi(tolerance / sigma) - 1
    sunk ~ binomial(attempts, p)
    sigma_degrees = sigma * 180 / pi
end
model = angle_error(; golf_data...)

Generated Stan ​

stan
functions {
// Return one normalized binomial log probability per observation, retaining shared distribution parameters.
vector binomial_lpmfs(
    array[] int y,
    array[] int args1,
    vector args2
) {
    return jbroadcasted_binomial_lpmfs(y, args1, args2);
}
vector jbroadcasted_binomial_lpmfs(
    array[] int x1,
    array[] int x2,
    vector x3
) {
    int n = dims(x1)[1];
    vector[n] rv;
    for(i in 1:n) {
        rv[i] = binomial_lpmfs(
            broadcasted_getindex(x1, i),
            broadcasted_getindex(x2, i),
            broadcasted_getindex(x3, i)
        );
    }
    return rv;
}
// Return one normalized binomial log probability per observation, retaining shared distribution parameters.
real binomial_lpmfs(
    int args1,
    int args2,
    real args3
) {
    return binomial_lpmf(args1 | args2, args3);
}
// Read element i of a container used in elementwise broadcasting.
int broadcasted_getindex(array[] int x, int i) {
    return x[i];
}
// Read element i of a container used in elementwise broadcasting.
real broadcasted_getindex(vector x, int i) {
    return x[i];
}
// Draw n independent binomial values, broadcasting scalar parameters across observations.
array[] int binomial_int_rng(
    int anontok__1,
    array[] int N,
    vector p
) {
    int n = anontok__1;
    if (dims(N)[1] != n) reject("binomial_rng: dim mismatch — `N` dim 1 (= ", dims(N)[1], ") does not match `n` (= ", n, "), inferred from `anontok__1` dim 1. `n` sizes: `anontok__1` dim 1 (= ", anontok__1, "), `N` dim 1 (= ", dims(N)[1], ").");
    if((n == 0)) {
        array[n] int rv;
        return rv;
    } else {
        return binomial_rng(N, p);
    }
}
}
data {
    int distance_n;
    real gap;
    vector[distance_n] distance;
    int sunk_n;
    array[sunk_n] int sunk;
    int attempts_n;
    array[attempts_n] int attempts;
}
transformed data {
    vector[distance_n] tolerance = asin((gap ./ distance));
}
parameters {
    real<lower=0> sigma;
}
transformed parameters {
    vector[distance_n] p = ((2 * Phi((tolerance / sigma))) - 1);
}
model {
    sigma ~ normal(0, 0.1);
    sunk ~ binomial(attempts, p);
}
generated quantities {
    vector[sunk_n] sunk_likelihood = binomial_lpmfs(sunk, attempts, p);
    array[attempts_n] int sunk_gen = binomial_int_rng(sunk_n, attempts, p);
    real sigma_degrees = ((sigma * 180) / 3.141592653589793);
}

Read the generated program as a check on the model specification. The bound observations belong in the data block, the positive error scale belongs in the parameters block, and the binomial observations contribute to the model block. The angle calculation is shared across those contributions. The model guide explains binding and generated blocks; the functions guide explains distribution functions.

Inference ​

This model has one free scalar. Numerical quadrature is sufficient to compute its posterior without a Markov chain. The generator evaluates the compiled Stan density on a grid in the logarithm of the angular standard deviation. Stan's unconstrained density includes the change-of-variables Jacobian, so normalizing the grid weights approximates integration in that coordinate. Omitting that Jacobian would define a different posterior.

The documentation build reads the saved summary and checks the hashes of the model source, generator, generated Stan program and summary. It does not rerun the fit. Changing any of those inputs invalidates the receipt and stops the build. This makes the displayed results attributable to a particular model and calculation while keeping ordinary documentation builds independent of fitting.

ParameterMedianCentral 95% interval
Angular SD (degrees)1.5271.483–1.572

The interval describes uncertainty about the shared angular standard deviation under this model and prior. It is not an interval for the angular error of a particular putt. That distinction matters when interpreting predictions: a replicated count depends both on uncertainty in the shared parameter and on binomial variation at the observed number of attempts.

Numerical checks ​

The generator compares the Stan log density with a separate calculation using Julia's normal and binomial distributions. Terms that are constant in the parameter may be omitted by Stan, so the comparison checks that the difference is constant across parameter values. The reported range measures departures from that constant, in log-density units. Near-unit success probabilities at the smallest error scales amplify floating-point differences between normal CDF implementations; the generator applies an explicit tolerance there.

CheckResult
Grid / refined grid (points)4001 / 8001
Median change on refinement (rad)0
Range of Stan − reference log density2.93e-07
Grid boundary probability mass0

The refined grid checks the posterior median's sensitivity to grid spacing. Boundary probability checks whether appreciable posterior weight accumulates at either end of the integration interval. These checks address numerical integration of the stated model. They do not establish that its geometric assumptions describe putting behavior, and they do not substitute for checking the observations against predictions. There are no convergence statistics for chains because this calculation uses no chains.

Predictions ​

At each observed distance, the calculation transforms every weighted parameter value into a success probability. It then integrates the binomial distribution at the corresponding number of attempts. The resulting intervals describe replicate success proportions, with the same attempt counts as the original data. Using the observed counts preserves the differing sampling precision across distances.

Compare the orange observations with the blue intervals and the shape of the blue probability curve. A persistent pattern of discrepancies across adjacent distances would suggest that the angle-only assumption misses structure. An isolated discrepancy has a different interpretation because these intervals are marginal for each distance, not a simultaneous band for the whole curve. The observed data were used to estimate the angular scale, so this is a posterior predictive comparison rather than an evaluation on held-out putts.

The model can be extended with a mechanism for distance control, but that would require another likelihood calculation and another checked result. This page keeps the inference and predictive comparison attached to the single model shown above. The prediction guide explains how conditioning and replay change the role of observations when constructing such extensions.

Reproduce

Fit key: c0ed7e556442cca2df5462bbb90ce1cc07bf1de919294e633a29a2d67f8fa944. Created: 2026-11-12T01:09:11.136 UTC.

Source · Instructions

Fit summary · Receipt · Generator

The shell command below reproduces this result from the repository root. It reruns the fit and is intentionally excluded from CI.

sh
julia --project=docs research/golf/fit.jl