See the neck
A y-versus-x scatter reveals the changing scale and where divergent transitions accumulate.
Diagnostics vignette · 0.8.0
Neal’s funnel shows why successful return status is not enough, and why a parameterization change usually beats tuning harder.
Available in JDistlib 0.8.0The geometry
Let y be normal with standard deviation 3 and x conditional on y be normal with variance exp(y). Negative y compresses x into a narrow neck while positive y permits a wide range. One Euclidean step size must traverse both regions.
DifferentiableLogDensity funnel = (state, gradient) -> {
double y = state[0], x = state[1];
double inverseVariance = Math.exp(-y);
gradient[0] = -y / 9.0 - 0.5
+ 0.5 * x * x * inverseVariance;
gradient[1] = -x * inverseVariance;
return -0.5 * y * y / 9.0 - 0.5 * y
- 0.5 * x * x * inverseVariance;
};Review
A y-versus-x scatter reveals the changing scale and where divergent transitions accumulate.
Chains may spend different proportions of time in the neck and mouth.
Low E-BFMI indicates that momentum refreshes do not move effectively across energy levels.
McmcDiagnosticReport report = McmcDiagnostics.analyze(
new String[] {"y", "x"}, chains);
ChartSpec pairs = DiagnosticGraphs.pairs("y", 0, "x", 1, chains);
ChartSpec energy = DiagnosticGraphs.energy(30, chains);
String review = InferenceHtmlReport.render(
"Funnel review", report, null, pairs, energy);Response order
Eight schools
// Sample mu, logTau, and standard-normal z[j].
double tau = Math.exp(logTau);
double thetaJ = mu + tau * z[j];This formulation decouples latent effects from a weakly identified group scale. The named eight-schools implementation in the example catalog includes the complete analytic gradient, and its test compares that gradient with finite differences.
Decision
Compare divergence counts, maximum depth, minimum E-BFMI, R-hat, bulk/tail ESS, and the same plots after reparameterization. Treat improvement as evidence; do not declare victory solely because one warning disappeared.