← Anatomy of a Transit · Deep dive for chapter 6
The theory behind the pipeline's error estimate: how Markov chains draw samples, how to recognise convergence and why a wrong valley can still look convincing. First on toy distributions, then on a simulated light curve.
While you scroll, each step sets the animation accordingly. Afterwards you can keep turning the dials freely; clicking a step restores it.
MCMC: the theory
Markov chain Monte Carlo draws samples from a distribution that is known only up to a constant factor. This chapter builds the method on toy distributions in two dimensions. Part 2 applies it to a light curve, the way the pipeline does.
By Bayes' theorem, the posterior is the product of likelihood and prior, divided by the evidence:
The numerator is quick to compute for any θ, the evidence is not: it is an integral over the whole parameter space. On a grid with 100 points per axis it costs 100d model evaluations for d parameters, so 108 for four parameters. Means and error bars are such integrals too. MCMC sidesteps both: it only needs ratios p(θ′|D)/p(θ|D), in which p(D) cancels, and replaces every integral by an average over samples.
The surface on the right is such a target distribution π(θ), banana-shaped here. Four chains wander across it.
A Markov chain is a sequence θ0, θ1, θ2, … in which every step depends only on the current point, not on the history:
If the transition rule satisfies detailed balance with the target distribution π,
then π is stationary: once the chain is distributed according to π, it stays so. If it can also reach every region and does not run in circles (ergodicity), it tends towards π from any start. Averages over the chain then approximate expectation values:
On the right the chains start far out and still find the target. The histogram below approaches the true distribution (line).
The simplest rule with detailed balance: from point θ, a candidate θ′ is drawn from a proposal distribution q, here a round Gaussian of width s. It is accepted with probability
For symmetric q the fraction reduces to π(θ′)/π(θ). Rejected means: the chain stays put and counts the old point once more. For a transit fit, ln π = −χ²/2 + const, so
A step to smaller χ² is always accepted, Δχ² = 2 only with 37 %, Δχ² = 10 with 0.7 %. On the right a chain runs slowly: the dashed circle is the proposal width, green an accepted, red a rejected proposal.
Consecutive points of a chain are correlated. How strongly is measured by the integrated autocorrelation time. From it follows how many independent samples a chain really contains:
Steps that are too small are almost always accepted but barely make progress: τ becomes large. Steps that are too large mostly land off target and are rejected: the chain stands still, and τ becomes large as well. The optimum lies in between. For Gaussian targets it is around 23 % acceptance rate for many parameters and around 44 % for one parameter (Roberts, Gelman & Gilks 1997).
On the right s = 0.15 is set, and the trace crawls. Drag the slider to about 1.7 and then to 6 and compare τ.
If a chain starts far out, its first points are still shaped by the start and not distributed according to π. This run-in phase (burn-in) is discarded, here the first 150 steps, shaded grey in the trace at the top right. It is over when all chains fluctuate in the same region without a trend. As a rule of thumb, a few tens of τ are discarded.
If the distribution is narrow and slanted because two parameters are strongly correlated, a round proposal fits poorly. Across the diagonal s has to be small, and then the chain barely moves along the diagonal. Goodman & Weare (2010) therefore run an ensemble of walkers. Walker k jumps along the line towards a randomly chosen other walker j:
The factor Zd−1 restores detailed balance. Because the jumps follow from the distances between the walkers themselves, they adapt to any stretching and rotation of the distribution (affine invariance). This is the algorithm of the widely used Python package emcee. Switch to Metropolis for comparison.
If π has two separate peaks, a chain can stay in the first one for a very long time: the way to the second leads through a valley in which almost every proposal is rejected. Gelman & Rubin (1992) therefore compare m chains with n points each:
Depending on how strict you are, values below 1.01 or below 1.1 count as converged. But R̂ only checks whether the chains agree, not whether they have found everything. If all start on the same peak, as set now, R̂ ≈ 1, and the second peak is still missing from the histogram. Set the start to “spread”: then chains land on both peaks, and R̂ raises the alarm.
MCMC on a transit
Now the same method runs on a simulated light curve, with the pipeline's settings. The free parameters are the mid-time Tc and the radius ratio Rp/R★; everything else is held fixed. The pipeline starts at the best fit, accounts for red noise via β and reports the median and the 16th/84th percentile.
For Gaussian, independent noise the log-likelihood is a sum over all data points. Red noise enters the errors through the β factor from chapter 5 of the main page:
Held fixed are the orbit (a/R★, b, P) and the limb darkening u₁, u₂ from tables. The priors are flat here: ΔTc within ±45 min around the prediction, k between 0.03 and 0.2. The landscape is laid out at the top left. The shaded areas are the 1σ, 2σ and 3σ regions of a two-dimensional Gaussian (Δχ²/β² = 2.3 / 6.2 / 11.8).
The walkers do not start just anywhere. First an optimiser looks for the minimum of χ², from five starting values for Tc spread over ±30 min around the prediction. The start with the smallest χ² wins. The walkers are released in a small cloud around it. That saves most of the run-in phase and protects against side valleys, as long as one of the five starts lands in the right valley.
At the top left the five optimisers run; at the bottom right is the profile: for each mid-time, the smallest χ² reachable with any k.
For comparison, the sixteen walkers here deliberately start off target, at ΔTc = +9 min and k = 0.118. Each walker makes one stretch move from part 1 per step. With ln π = −χ²/(2β²) this becomes:
The first 80 steps count as the run-in phase and do not enter the result.
After the run-in phase, the positions of all walkers are samples from the posterior. The pipeline summarises them with percentiles:
For skewed distributions the two sides have different lengths, which is why + and − are reported separately. At the bottom, fifteen randomly drawn models lie over the data.
Correlated noise contains less independent information than the number of points suggests. That is why all σi are multiplied by β. Because ln 𝓛 is thereby divided by β², the posterior becomes wider by exactly the factor β in every direction:
The settings are β = 1.22 and 9.4 ppt per point, as for HAT-P-33b. The simulation has only 180 points instead of 1077, so its error is larger than for the real measurement.
Measurement: HAT-P-33b, 1077 frames of 20 s, 9.4 ppt per frame, β = 1.22: Tc ± 2.2 min.
Now the ingress is missing, because the observation only begins at mid-transit. In addition, shortly after egress a thin cloud pushes the flux down by 10 ppt for 10 minutes. This gives the profile a second valley at ΔTc ≈ +25 min: a model with a later egress explains the cloud as the remainder of the transit. The walkers were released in this side valley, just as happens when the optimiser gets stuck there.
The result looks flawless: narrow histogram, normal acceptance rate, R̂ ≈ 1. Yet it is off by about 25 min. No walker crosses the ridge between the valleys, because every proposal there is rejected. And R̂ only compares walkers that all stand in the same valley. This is exactly the possibility the ExoClock reviewer pointed out: a local minimum at egress shifts Tc and with it the O−C.
With the pipeline's five starting values, the optimisers from −30, −15 and 0 min find the right valley here, while those from +15 and +30 min get stuck in the side valley. The smaller χ² decides. That protects you as long as the right valley is also the deepest. With “New data” you can try out how often the noise makes the side valley deeper. Three additional checks cost little:
Profile scan: compute Δχ²prof(Tc) over the whole window (bottom right). A second valley with Δχ²/β² below about 10 is a warning sign.
Widely spread walkers: if you start them spread over ±30 min, some land in the side valley. The histogram gets two humps, and R̂ rises far above 1.1.
Mask the egress: repeat the fit once without the disturbed minutes. If Tc changes by more than its error, the result is not robust.
Measurements: HAT-P-33b ran with 15 chains and reached R̂ = 1.003. For KPS-1b the points scattered at egress, and the ExoClock reviewer suspects exactly such a local minimum in the fit. There, the profile scan is the first test.