---
title: "Fit shared distance errors with a covariance matrix"
description: "Derive generalized least squares, transform the Hubble uncertainty and calculate which relative distances cancel a shared anchor error."
canonical_url: "https://sandboxphysics.com/stories/distance-ladder/shared-errors-in-the-ladder/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/distance-ladder/shared-errors-in-the-ladder/"
last_modified: "2026-10-28"
---

[How the cosmic distance ladder acquires a scale](https://sandboxphysics.com/stories/distance-ladder/)

L3 · Cosmic distance ladder

# Fit shared distance errors with a covariance matrix

Sandbox Physics · 2026-10-28

A common anchor error moves several fitted distances together. A covariance matrix records that motion, so the fit can distinguish one shared uncertainty from many independent measurements. We first solve a two-galaxy example, then derive the full linear fit used by the frozen 87-row subsystem.

## Before you begin

Complete Join Cepheids and supernovae in one distance model. Matrix multiplication means taking coefficient-weighted sums. Variance, covariance and Cholesky whitening are introduced here; derivatives of a quadratic are the only calculus used.

## Two galaxies inherit the same starting length

Let each fitted host modulus contain one shared anchor error plus its own independent comparison error. Assume all errors have mean zero and the independent comparison errors are uncorrelated with the anchor. Variance is the mean squared fluctuation around the true value. Covariance is the mean product of two fluctuations; a positive value means they tend to move in the same direction.

Take an anchor uncertainty 0.032 magnitude and independent host uncertainties 0.050 and 0.080. The host variances are 0.003524 and 0.007424 square magnitudes; their covariance is 0.001024. Subtract the host moduli. The same anchor error cancels exactly, leaving variance 0.008900 and standard deviation 0.09434 magnitude. Treating the two total errors as independent would give 0.10463 magnitude and miss that cancellation.

$$
\mu_i=\mu_{i,\mathrm{true}}+a+e_i,\quad \operatorname{Cov}(\mu_1,\mu_2)=\sigma_a^2,\quad \operatorname{Var}(\mu_2-\mu_1)=\sigma_{e_1}^2+\sigma_{e_2}^2
$$

The shared random variable a appears once in each distance. In the difference its coefficient is zero. For the average distance its coefficient remains one, and the full anchor uncertainty survives the average.

Reading: Riess et al. · Reid

## Whiten the observations before taking a squared distance

Stack the prepared observed values into a column y. The design matrix A predicts them from the parameter column q. The residual is observed minus predicted. Let C be the supplied observation covariance, in square magnitudes. A usual sum of squared residuals would overcount a shared fluctuation. Weighting with the inverse covariance measures a fluctuation in units of the allowed correlated error.

A positive-definite covariance has a Cholesky factor: a lower-triangular matrix multiplied by its transpose returns C. Solve this triangular system for every design column and the observed vector. The transformed errors have unit covariance, so ordinary least squares on the transformed system gives generalized least squares on the original one. No explicit inverse of the large observation covariance is needed.

$$
C=LL^{\mathsf T},\quad \widetilde A=L^{-1}A,\quad\widetilde{\boldsymbol y}=L^{-1}\boldsymbol y,\quad\chi^2=\|\widetilde{\boldsymbol y}-\widetilde A\boldsymbol q\|^2
$$

A triangular solve implements inverse multiplication. The norm squared adds the squares of the whitened residuals. A failed positive-definiteness check is a data or model problem to diagnose before fitting.

Reading: Riess et al. · PantheonPlusSH0ES DataRelease

## Differentiate the quadratic to solve the fit

Expand the whitened squared residual and differentiate with respect to each parameter. Setting all derivatives to zero gives the normal equations. If every parameter direction changes some predicted observation, the normal matrix is invertible. Under the stated linear model with known Gaussian observation covariance, the estimator covariance is the inverse normal matrix.

This uncertainty keeps all cross-parameter terms. A Cepheid zero point, host modulus and supernova luminosity can partially trade against one another; reading only the diagonal entries would hide these combinations. Removing the anchor makes the normal matrix singular, exactly as the previous chapter’s null vector predicts.

$$
\widehat{\boldsymbol q}=(A^{\mathsf T}C^{-1}A)^{-1}A^{\mathsf T}C^{-1}\boldsymbol y,\qquad S=(A^{\mathsf T}C^{-1}A)^{-1}
$$

The estimate is linear in the observed column. Propagating Cov(y)=C through that linear map leaves S. The numerical code solves factored systems instead of constructing a large explicit inverse.

Reading: Riess et al.

## Transform the logarithmic Hubble uncertainty carefully

The fit is Gaussian in the logarithmic parameter u, whose variance is the eighth diagonal element of S. A one-standard-deviation interval in u transforms monotonically to an asymmetric interval in the Hubble constant. Exponentiating the fitted u gives the centre used here, the median of the transformed Gaussian reference curve. Its density mode is slightly lower because a change of variables includes a Jacobian.

For a Bayesian reading, a flat density in all eight linear parameters gives this proper Gaussian posterior when the fit has full rank; the released summary rows remain part of the conditioned model. A flat density in the Hubble constant would be a different prior. With no anchor, the flat-linear-parameter posterior is improper along the free scale, so we show only a flat likelihood profile and identifiable relative distances.

$$
H_{0,\mathrm{med}}=10^{\widehat u/5},\qquad I_{68.27\%}=\left[10^{(\widehat u-\sigma_u)/5},\,10^{(\widehat u+\sigma_u)/5}\right]
$$

Numerical Hubble values use km/s/Mpc. The plotted transformed density includes the factor 5 divided by H0 times ln(10). A confidence interval transformed from Gaussian u has the same coverage under this fixed linear-Gaussian model.

Reading: Riess et al. · PantheonPlusSH0ES DataRelease

## Saved results show both shared and differential precision

The selected subsystem has 87 observations and eight parameters. It gives a conditional Hubble value 66.3049 and a central interval 62.2356–70.6403 in km/s/Mpc. The physical Cepheid slope is−3.51866 magnitudes per dex. The result uses only two calibrated supernova hosts and released metallicity and broad-slope summaries; it is a smaller question than the full paper’s fit.

The host-modulus correlation is 0.6353. Their difference is $3.84091\pm0.10910$ magnitudes. Multiplying only the anchor standard deviation by eight increases the absolute-distance uncertainty, but the relative-modulus variance stays fixed to numerical precision. That is the simple two-galaxy cancellation reappearing inside the joint fit.

| Calculation | Hubble median | Relative-modulus sigma, mag |
| --- | --- | --- |
| Full selected covariance | 66.3049 | 0.109103 |
| Diagonal-only counterfactual | 66.8289 | 0.0888183 |
| Drop released metallicity summary | 68.3178 | 0.139186 |
| Remove absolute anchor | Free scale | 0.109103 |

Reading: PantheonPlusSH0ES DataRelease · Riess et al.

## Try the observation

### [Separate shared uncertainty from relative precision](https://sandboxphysics.com/labs/supernova-distance-expansion/)

1. In Distance ladder, keep the zero-point shifts at zero and increase Shared anchor uncertainty multiplier to eight. Predict how the Hubble interval and relative-modulus uncertainty should change.
2. Open the shared covariance values, then remove the anchor. Explain why the absolute interval disappears while the relative-modulus uncertainty survives.

## Exercises and explained answers

Two galaxies have 0.04 magnitude shared anchor error and 0.06 magnitude independent error each. Find the uncertainty of their average modulus and their difference.

The average retains the whole anchor variance plus half the independent variance:0.0016 plus 0.0018 equals 0.0034, giving 0.05831 magnitude. The difference cancels the anchor and has variance twice 0.0036, giving 0.08485 magnitude.

A diagonal-only fit happens to yield a Hubble value close to the correlated fit. Does that validate its error bar?

No. The central value and covariance depend on different matrix combinations. The saved example shifts the median only slightly but reduces relative-modulus sigma from 0.10910 to 0.08882. Check the full covariance and the uncertainty of each identifiable parameter combination.

Transfer the shared-error model to two thermometers calibrated with the same reference. Which quantity benefits when the common calibration cancels?

Their temperature difference cancels a common additive calibration error. Their average absolute temperature still contains it. The algebra is the same as a relative galaxy modulus versus an absolute distance scale.

[Previous: Join Cepheids and supernovae in one distance model](https://sandboxphysics.com/stories/distance-ladder/joining-the-rungs/) [Next: Reproduce a correlated SH0ES distance-ladder subsystem](https://sandboxphysics.com/stories/distance-ladder/shoes-subsystem-tutorial/)

## Sources and calculation scope

1. [Riess et al., A Comprehensive Measurement of the Local Value of the Hubble Constant, arXiv:2112.04510 v 3 (2022)](https://arxiv.org/abs/2112.04510v3)

   Sections 2.1 and 4 define the joint model and calibrations. Section 5, Table 5 and Figures 14–16 report the full fit and its correlations; sections 6–7 discuss variants and comparisons. All paper-specific claims here refer to this fixed version.

2. [PantheonPlusSH0ES DataRelease, commit c447f0fea703fcd0fff57de5000947b5ca81286b](https://github.com/PantheonPlusSH0ES/DataRelease/tree/c447f0fea703fcd0fff57de5000947b5ca81286b/SH0ES_Data)

   The ally, alll and allc FITS arrays contain 3492 prepared observations,47 parameter columns and the full covariance. The public tutorial retains 87 observations and every nonzero model column they use. The table 2.README explicitly warns against refitting from its diagonal errors.

3. [Reid, Pesce & Riess, An Improved Distance to NGC4258 and its Implications for the Hubble Constant, arXiv:1908.05625 v 2 (2019)](https://arxiv.org/abs/1908.05625v2)

   The geometric maser distance is 7.576 Mpc, with statistical uncertainty 0.082 Mpc and systematic uncertainty 0.076 Mpc. The paper also calibrates the tip of the red giant branch with this anchor, including a discussion of common starting and ending rungs.
