Read the optimal statistic and its null tests first; it defines every quantity used here. The reference paper is NANOGrav Collaboration, 2023, arXiv version 1.
Get the materials and run them
Download the scripts, frozen inputs and saved outputs 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, outputs and failure cases 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=[Fred∣M∣r] and stores Q=WTN−1W. Here Fred 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 Fred, so all of them can be computed from Q alone.
From inner products to pair correlations
Given a red-noise prior φ on Fred, the Woodbury identity gives the noise-weighted products without ever forming the full covariance:
Eliminating the three timing columns of R by a Schur complement gives RG. The signal blocks are X=RG[F,r] and Z=RG[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×10−7Hz as its white floor; it is the preferred model. The common-process-only model ignores intrinsic red noise and keeps only a γ=13/3 process at A=2.4×10−15.
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.
- White noise counted twice. The published-spectrum model inflates the noise and drops the result from 3.8 to 2.4 null standard deviations.
- 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.
- Timing model not marginalised. Without the spin projection, A^2 drops by about a third, to 3.31×10−31, while the S/N barely moves.
- Amplitude not reproduced. The preferred model recovers 0.085 of the published A2=5.76×10−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×10−4 and Allen's single-source variance within 9×10−5. Allen, 2022, eqs. 2.4 and 2.6 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.
Printed values that differ from the recomputation
The anisotropy paper is NANOGrav Collaboration, 2023b. 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±1 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.