Why Marginalization Improves Inverse TEXAS Sampling#
This note explains why the inverse TEXAS models marginalize over the forward-calibration ensemble inside the likelihood (manuscript Appendix B, Eqs. B2–B3) instead of sampling one temperature per observation per calibration draw — the “full latent” formulation that was tried first and is now archived. The marginal form runs much faster and gives cleaner posteriors. The goal is to make this clear for a scientific audience, without assuming a background in Bayesian computation.
1. The Two Approaches#
(A) The “full latent” formulation (archived)#
For each data point
n(e.g., a core-top sample), and each forward-model drawm(the ensemble), we introduced an explicit latent parameter:t_est[n, m]
That means:
Number of unknowns grows with both the number of samples (N) and the ensemble size (M).
For N ≈ 1,200 and M ≈ 100, that’s ~120,000 latent parameters.
The model then combines all of these latents into the likelihood.
(B) The marginalized formulation (shipped)#
Instead of sampling
t_est[n, m]for every ensemble draw, we only keep a single latent parameter per sample:t_est[n]
We then compute the likelihood by marginalizing over the ensemble:
log p(data[n] | t_est[n]) = log( 1/M * Σ p(data[n] | t_est[n], params_m) )
This uses the
log_sum_exptrick in Stan, which is stable and efficient.Result:
Only N ≈ 1,200 latent parameters (independent of M).
The ensemble variability is still accounted for, but without exploding the parameter space.
2. Side-by-Side Stan Sketch#
Here’s the essential difference, shown in simplified pseudo-Stan code:
Full Latent Version#
parameters {
matrix[N, M] t_est; // each sample × ensemble
}
model {
for (m in 1:M) {
vector[N] mu_scaledRI = logistic_fn(t_est[, m], params[m]);
scaledRI ~ normal(mu_scaledRI, sigma[m]);
}
}
Marginalized Version#
parameters {
vector[N] t_est; // only one per sample
}
model {
for (n in 1:N) {
vector[M] log_lik_m;
for (m in 1:M) {
real mu_scaledRI = logistic_fn(t_est[n], params[m]);
log_lik_m[m] = normal_lpdf(scaledRI[n] | mu_scaledRI, sigma[m]);
}
// Marginalize using log-sum-exp
target += log_sum_exp(log_lik_m) - log(M);
}
}
Key change: Instead of sampling t_est[n, m] for all ensemble members, we sample only t_est[n] and analytically average over ensemble members.
3. Why Marginalization is Better#
3.1 Fewer Parameters#
Full latent model: ~120,000 parameters.
Marginal model: ~1,200 parameters.
Sampling speed scales badly with dimensionality. By cutting the number of unknowns 100-fold, the sampler spends far less time per iteration.
3.2 Better Posterior Geometry#
In the full latent model,
t_est[n, m]are strongly correlated acrossm.The sampler has to “wiggle” through a very tangled space.
Marginalization collapses these correlations analytically, so the sampler only needs to explore the temperature dimension.
3.3 Cleaner Effective Sample Size (ESS)#
ESS measures how many “independent” samples you get out of MCMC.
With fewer parameters and smoother geometry, marginal models give higher ESS per unit time.
This means your credible intervals stabilize faster.
4. Practical Impact#
Speed: Warm-up and sampling progress much faster, because each iteration moves
Nparameters instead ofN × M.Stability: Fewer divergences, better adaptation of step sizes, and cleaner R̂ diagnostics.
Scalability: Larger ensembles cost only likelihood evaluations, not parameters. The manuscript uses M = 300 for the global coretop reconstructions and M = 500 (the package default for a 4,000-draw posterior) for the downcore ones.
5. Analogy (for non-statisticians)#
Think of this like averaging weather forecasts:
Full latent model: You ask 100 forecasters for 1,200 cities, and try to track every single opinion separately. That’s 120,000 numbers bouncing around.
Marginalized model: You only track the city-level temperature (1,200 numbers), and average the forecasts mathematically in the likelihood. You still capture uncertainty from forecasters, but you don’t waste time simulating each one.
6. Key Takeaway#
Marginalization trades a slightly more complex likelihood calculation for a massive reduction in sampling complexity.
The science is the same (we still respect ensemble variability).
But computationally, the marginalized model is leaner, faster, and more robust.
This is why the three inverse Stan models shipped with TEXAS are all marginal, and why predict_T_from_proxyObs has no other path.
7. The deterministic point inverse, and when not to use it#
TEXAS.inverse_generalized_logistic_fixed_upper inverts the forward curve for a single parameter set. It is not a reconstruction.
For the published T₀-shift calibration the nonthermal predictors shift the curve’s location, so the point inverse is the thermal inverse evaluated at the shifted location:
T0_eff = t0 + gamma_G23·gdgt23ratio + gamma_NO3·log10(no3) [NO₃ term only where 0 < no3 < no3_cutoff]
x = T0_eff − ln(((1 − b) / (y − b))**v − 1) / k
i.e. call inverse_generalized_logistic_fixed_upper(y, t0=T0_eff, k=k, b=b, v=v) with the sample’s own predictor values folded into t0. (The companion inverse_generalized_logistic_fixed_upper_multivariate is the point inverse of the additive formulation of the initial submission — it subtracts β_G23·gdgt23ratio + β_NO3·log10(no3) from the response first — and is kept for the archived GHEA posteriors.) Predictors are inputs to be supplied, not quantities solved for: pass the same covariate values that applied to those observations.
The thermal inverse is defined only for b < y < 1. Values outside that range are physically unreachable for the given parameters and come back as np.nan, with a single RuntimeWarning if any occur. That NaN is the honest answer, and it is the first reason this function is not a reconstruction: the Bayesian path returns a posterior in exactly that region, driven by the prior, which is informative in a way a NaN is not.
The second reason is uncertainty. Feeding this function the posterior means of t0, k, b and v gives one number per sample and no interval — and the plug-in estimate is not the median of the marginal posterior, because the inverse is non-linear. For an uncertainty-aware reconstruction that marginalises over the full forward posterior, use TEXAS.predict_T_from_proxyObs, which is the Stan path this page describes.
Use the point inverse for what it is good at: drawing a single calibration curve on a figure, checking an algebraic identity against the forward function, or sanity-checking one parameter set by hand.