---
title: "Recompute a Hellings–Downs statistic from NANOGrav 15-year data"
description: "Rerun a simplified optimal statistic on frozen NANOGrav products, test it against phase shifts and sky scrambles, and see which noise choices break it."
canonical_url: "https://sandboxphysics.com/stories/pulsar-timing-arrays/recompute-the-optimal-statistic/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/pulsar-timing-arrays/recompute-the-optimal-statistic/"
last_modified: "2026-11-14"
---

[Pulsar timing arrays and the Hellings–Downs curve](https://sandboxphysics.com/stories/pulsar-timing-arrays/)

# Recompute a Hellings–Downs statistic from NANOGrav 15-year data

Sandbox Physics · 2026-11-14

This guide recomputes a simplified optimal statistic from public NANOGrav 15-year products and calibrates it the way the collaboration did, with phase shifts and sky scrambles. With the preferred noise model, the Hellings–Downs statistic of the real data sits $3.8$ standard deviations of its phase-shift null above zero: one of 1000 phase shifts did as well, so $p=0.002$. Sky scrambles give $3.4$ standard deviations and $p=0.004$. The guide does not reproduce the published amplitude: the recovered amplitude squared is about one twelfth of the published value, and the reason is not verified here. It also records three ways to get a misleading answer and the places where the papers and this recomputation disagree.

Read [the optimal statistic and its null tests](https://sandboxphysics.com/stories/pulsar-timing-arrays/optimal-statistic-and-null-tests/) first; it defines every quantity used here. The reference paper is [NANOGrav Collaboration, 2023, arXiv version 1](https://arxiv.org/abs/2306.16213v1).

## Get the materials and run them

Download the [scripts, frozen inputs and saved outputs](https://sandboxphysics.com/stories/pulsar-timing-arrays/materials/pulsar-timing-optimal-statistic.zip) and extract the archive. It holds six Python files for the statistic, four for the independent checks, two frozen input files, the four saved JSON outputs and a README. Everything uses only the Python standard library. The saved run used Python 3.9.6 and took 13 seconds.

```
cd pulsar-timing-optimal-statistic/optimal-statistic
python3 reproduce_optimal_statistic.py ../frozen-inputs ../my-run
```

The run writes inputs.json, outputs.json and failure-cases.json. Apart from the run time they should match the saved [inputs](https://sandboxphysics.com/stories/pulsar-timing-arrays/materials/inputs.json), [outputs](https://sandboxphysics.com/stories/pulsar-timing-arrays/materials/outputs.json) and [failure cases](https://sandboxphysics.com/stories/pulsar-timing-arrays/materials/failure-cases.json) exactly, because both null distributions use fixed seeds.

## What the frozen inputs are

The frozen inputs are derived from two public Zenodo records, both under CC-BY-4.0: the NANOGrav 15-year data set version 2.1.0 (record 16051178) and the per-pulsar noise spectra version 1.0.0 (record 8092346). An extraction script in the archive rebuilds them from those downloads in under a second. It writes no raw residual tables.

For each of the 67 pulsars the extraction averages the narrowband residuals by epoch, builds the basis $W=[F_{\mathrm{red}}\,|\,M\,|\,r]$ and stores $Q=W^{\mathsf T}N^{-1}W$. Here $F_{\mathrm{red}}$ holds sines and cosines at $k/T$ for $k=1$ to $14$, $M$ holds an offset, $t/T$ and $(t/T)^2$, $r$ is the residual vector, and $N$ is the diagonal white noise from the averaged uncertainties. Every noise model below is a different prior on $F_{\mathrm{red}}$, so all of them can be computed from $Q$ alone.

**Table 5.1** Choices of the saved run, compared with the NANOGrav analysis.

| Quantity | This guide | NANOGrav 15-year paper |
| --- | --- | --- |
| Pulsars and pairs | 67 and 2211 | 67 and 2211 |
| Time span $T$ | 16.03 yr | 16.03 yr |
| Signal frequencies | 5 bins, $\gamma=13/3$ | 14 bins, $\gamma=13/3$ |
| Red-noise frequencies | 14 bins | 30 bins |
| Timing model | offset, spin, spin-down | full timing model and DMX |
| White noise | averaged TOA uncertainties | EFAC, EQUAD and ECORR per backend |
| Pulsar noise | frozen NG15 spectra, 3 variants | sampled power laws |
| Null trials | 1000 phase shifts, 1000 sky scrambles | 400 000 phase shifts, sky scrambles |

## From inner products to pair correlations

Given a red-noise prior $\varphi$ on $F_{\mathrm{red}}$, the Woodbury identity gives the noise-weighted products without ever forming the full covariance:

$$
R=Q-Q_{\cdot F}\big(\varphi^{-1}+Q_{FF}\big)^{-1}Q_{F\cdot}.
$$

Eliminating the three timing columns of $R$ by a Schur complement gives $R_G$. The signal blocks are $X=R_G[F,r]$ and $Z=R_G[F,F]$, where $F$ is now the first ten columns. These are the quantities in eqs. 9 and 10 of the paper, with the spin fit marginalised.

```
import json
import optimal_statistic as statistic
import pulsar_projections as projections

products = json.load(open('../frozen-inputs/ng15-noise-weighted-inner-products.json'))
pulsar = products['pulsars'][0]
projection, covariance = projections.projections_for_pulsar(pulsar, 'spectrum-minus-white-floor')
print(pulsar['name'], len(projection), len(covariance))
print(round(statistic.hellings_downs(1.5707963), 4))
```

Run from the optimal-statistic folder, this prints B1855+09 with a ten-element projection and a ten-by-ten covariance, then $-0.1449$, the Hellings–Downs value at a right angle.

## Three noise models

The NG15 noise-spectra README states that each per-pulsar spectrum already contains white noise, the common-process power and any significant intrinsic red noise. That forces a choice.

The published-spectrum model uses the spectra as given and so counts white noise twice. The spectrum-minus-white-floor model subtracts each spectrum's value at $2\times10^{-7}\,\mathrm{Hz}$ as its white floor; it is the preferred model. The common-process-only model ignores intrinsic red noise and keeps only a $\gamma=13/3$ process at $A=2.4\times10^{-15}$.

**Table 5.2** Saved results, real observation recomputed with the simplified model.

| Noise model | $\hat A^2$ | Formal S/N | Phase-shift null spread | Null standard deviations | Phase-shift p | Sky-scramble p |
| --- | --- | --- | --- | --- | --- | --- |
| published spectrum | $3.46\times10^{-31}$ | 0.41 | 0.17 | 2.4 | 0.013 | 0.028 |
| minus white floor | $4.90\times10^{-31}$ | 0.72 | 0.19 | 3.8 | 0.002 | 0.004 |
| common process only | $5.49\times10^{-30}$ | 8.31 | 7.45 | 1.1 | 0.14 | 0.10 |

Read the null columns, not the formal S/N. With 1000 trials the smallest possible p-value is $1/1001$, so $p=0.002$ means one exceedance. The three-shape fit for the preferred model gives S/N values of $0.39$ for the Hellings–Downs shape, $0.66$ for a monopole and $0.12$ for a dipole, all in units of the formal spread.

## Failure cases

These come from the saved failure-cases.json.

1. White noise counted twice. The published-spectrum model inflates the noise and drops the result from 3.8 to 2.4 null standard deviations.
2. Intrinsic red noise ignored. The formal S/N jumps to 8.3, but the phase-shift null is just as wide, 7.4, and the result is only 1.1 null standard deviations. Unmodelled red noise in a few pulsars makes every pair noisy. A large formal S/N without a null test means nothing.
3. Timing model not marginalised. Without the spin projection, $\hat A^2$ drops by about a third, to $3.31\times10^{-31}$, while the S/N barely moves.
4. Amplitude not reproduced. The preferred model recovers $0.085$ of the published $A^2=5.76\times10^{-30}$, and its null spread is $0.19$ instead of about one. Both say the noise model is too large for the post-fit residuals. The likely cause is power absorbed by the full timing and DMX fit that this guide leaves out. That is a hypothesis, not a verified result.

## Independent checks

The verification scripts do not reuse the closed-form curve to test itself. A direct sky quadrature of explicit antenna patterns matches the NANOGrav closed form within $3.5\times10^{-4}$ and Allen's single-source variance within $9\times10^{-5}$. [Allen, 2022, eqs. 2.4 and 2.6](https://arxiv.org/abs/2205.05637v3) An ensemble of 60 plane waves, averaged over 10 000 realisations, follows the curve with a largest deviation of $1.09$ standard errors. An offline injection study with synthetic coefficients at the real positions measures false alarms and coverage; its numbers are in the [optimal-statistic chapter](https://sandboxphysics.com/stories/pulsar-timing-arrays/optimal-statistic-and-null-tests/).

## Printed values that differ from the recomputation

**Table 5.3** Places where a paper and this recomputation, or two papers, disagree. Each is reported as found; none is corrected.

| Item | Printed | Used or found | Note |
| --- | --- | --- | --- |
| First zero crossing of the curve | $49.2^\circ$ | $49.32^\circ$ | the formula is $+0.001$ at $49.2^\circ$ |
| Antenna-pattern denominator | $1-\hat\Omega\cdot\hat p$ in the anisotropy paper | $1+\hat\Omega\cdot\hat p$ | same function; there $\hat\Omega$ points to the source |
| Curve normalisation | $\tfrac12$ at zero separation | Allen uses $\tfrac13$ | ratio $\tfrac23$ |
| Data version | the 2023 papers used the first release | residuals from version 2.1.0 | results may differ slightly for that reason |
| Signal bins in the optimal statistic | 14 | 5 | a deliberate simplification |

The anisotropy paper is [NANOGrav Collaboration, 2023b](https://arxiv.org/abs/2306.16221v1). Two classic papers were not opened for this guide: Hellings and Downs 1983 and Gair and colleagues 2014. Their results are used only as quoted in the NANOGrav paper.

## What this recomputation does not show

It does not measure the background amplitude, does not reproduce the formal S/N of $4\pm1$ quoted in Section 4 of the paper, and does not test the Bayesian analysis or the Bayes factors. It shows that a simple, transparent statistic on the public products already finds Hellings–Downs-shaped correlations well outside what phase shifts and sky scrambles produce, and that the conclusion depends on how noise is modelled.

## [Try it in the pulsar-timing-array Lab](https://sandboxphysics.com/labs/pulsar-timing-array-correlations/)

Set the array to eight pulsars and compare the spread with the full array.

## Sources

1. [NANOGrav Collaboration, 2023, arXiv version 1](https://arxiv.org/abs/2306.16213v1)
2. [Allen, 2022, eqs. 2.4 and 2.6](https://arxiv.org/abs/2205.05637v3)
3. [NANOGrav Collaboration, 2023b](https://arxiv.org/abs/2306.16221v1)

## Keep reading

Pulsar timing arrays and the Hellings–Downs curve · Reading path

### From one ticking pulsar to a Galaxy-sized detector

1. [Article **How can a pulsar timing array tell gravitational waves from a bad clock?**](https://sandboxphysics.com/stories/pulsar-timing-arrays/gravitational-waves-or-a-bad-clock/)
2. [Article **What a pulsar timing residual measures**](https://sandboxphysics.com/stories/pulsar-timing-arrays/what-a-timing-residual-measures/)
3. [Article **Deriving the Hellings–Downs curve**](https://sandboxphysics.com/stories/pulsar-timing-arrays/deriving-the-hellings-downs-curve/)
4. [Article **The optimal statistic and its null tests**](https://sandboxphysics.com/stories/pulsar-timing-arrays/optimal-statistic-and-null-tests/)
5. [You are here **Recompute a Hellings–Downs statistic from NANOGrav 15-year data**](https://sandboxphysics.com/stories/pulsar-timing-arrays/recompute-the-optimal-statistic/)
6. [Article **Reading the NANOGrav 15-year evidence for a gravitational-wave background**](https://sandboxphysics.com/stories/pulsar-timing-arrays/reading-the-nanograv-15-year-evidence/)
