Skip to main content
Sandbox Physics
Gravitational-wave populations: mass gap, pairing and selection

Recompute the black-hole mass spectrum from frozen GWTC-3 data

Sandbox Physics ·

The frozen O3b inputs give a steep intrinsic mass spectrum once the calculation accounts for missed mergers. Recompute all three outputs and inspect the failures on your own machine. The environment uses Python 3.9.6, NumPy 2.0.2 and SciPy 1.13.1. The original data live in the GWTC-3 parameter-estimation release and the O3 search-sensitivity release. For background on the files, see the GWOSC tutorials.

Open the real O3b comparison

The method itself is derived in hierarchical inference with selection effects. This page is about running it and reading what comes out.

What is in the materials folder

Every file below is served unchanged from this site, so its SHA-256 fingerprint matches the one in the scripts README.

Table 5.1 Inputs. Masses in solar masses (source frame); redshift dimensionless.
FileContentOrigin
inputs/o3b-bbh-posterior-samples.csv23 events, 1500 samples each of m1m_1, m2m_2, zzreal: GWTC-3 C01:Mixed cosmological samples
inputs/o3b-bbh-found-injections.csv20 000 found injections with m1m_1, m2m_2, zz and the draw densityreal: O3b BBH sensitivity injections
inputs/o3b-bbh-found-far.csvreported false-alarm rate for each of the 20 000 rowsLVK O3b injection record
inputs/frozen-subset-manifest.jsonevent labels, sample counts, input hashes, injection totalswritten by the freeze step
inputs/gwosc-gwtc3-confident-events.jsonthe GWOSC event list used to choose eventsreal: GWOSC event service

Both data products are released by the LIGO, Virgo and KAGRA collaborations under the CC BY 4.0 licence. GWTC-3 parameter-estimation release, Zenodo 5546663 O3 search sensitivity release, Zenodo 5546676

The scripts are population_model.py (cosmology, population density and the parameter-estimation prior), frozen_inputs.py (readers and hash checks), hierarchical_likelihood.py (event and selection terms on the grid), hierarchical_mass_inference.py and injection_recovery.py. The freeze step, freeze_public_subset.py, needs the network and h5py; you do not have to run it.

The catalog comparison adds observed_replay.py and predictive_mass.py. The optional FAR extractor reads the original 39.9 MB injection file.

Step 1: download and check the inputs

mkdir gw-population && cd gw-population
xargs -I '{}' curl -fsS --create-dirs --output '{}' \
  'https://sandboxphysics.com/stories/gravitational-wave-populations/materials/{}' <<'FILES'
README.md
requirements.txt
population_model.py
frozen_inputs.py
hierarchical_likelihood.py
hierarchical_mass_inference.py
injection_recovery.py
observed_replay.py
predictive_mass.py
inputs/o3b-bbh-found-far.csv
inputs/o3b-bbh-posterior-samples.csv
inputs/o3b-bbh-found-injections.csv
inputs/frozen-subset-manifest.json
inputs/gwosc-gwtc3-confident-events.json
FILES
shasum -a 256 inputs/*.csv

Compare the three checksums with the saved values.

00d928169fa2d769428adfd964a158a5a97b04557cc46181a217133b69ad178c  inputs/o3b-bbh-found-far.csv
2e6cfeaba297971ae88d36d3e13521f79e4c63d3a47bb538dc531173c320d41c  inputs/o3b-bbh-found-injections.csv
11f1e21f10167b7d54e7beb4a478d90d7b4ef8cd2398193fd6fa4b975b0d60f8  inputs/o3b-bbh-posterior-samples.csv

The inference script checks the same fingerprints against the manifest and stops if an input differs. The catalog replay also checks the third CSV.

Step 2: set up the environment

python3 -m venv .venv
.venv/bin/pip install -r requirements.txt

We tested Python 3.9.6, NumPy 2.0.2 and SciPy 1.13.1 on an arm64 Mac.

Step 3: run the grid inference

.venv/bin/python hierarchical_mass_inference.py
shasum -a 256 outputs/hierarchical-inference-results.json

It takes about 0.3 seconds. The fingerprint on our build is 761339bd80c91b1933ad73ce5da0d8e9a90d34fc520acb1d1890cd64fd8424ec, and our copy is published as outputs/hierarchical-inference-results.json for comparison. The part to read first is the corrected posterior:

"corrected": {
  "alpha": {"median": 2.556, "lower90": 1.837, "upper90": 3.173},
  "mMax": {"median": 54.15, "lower90": 46.13, "upper90": 74.68},
  "peak": {"alpha": 2.45, "mMax": 50.5},
  "selectionEffectiveAtPeak": 9764.4,
  "detectableFractionAtPeak": 0.000995,
  "minimumEventEffectiveAtPeak": 12.47,
  "weakestEventAtPeak": "GW191109_010717",
  "farrThreshold": 92,
  "posteriorMassInFlaggedCells": 0.364
}

The excerpt rounds the stored numbers. Here alpha is the power-law slope of p(m1)∝m1−αp(m_1)\propto m_1^{-\alpha}, mMax the sharp upper edge in solar masses, and the 90% bounds come from the marginal posterior on the grid. The file also stores both marginals, so you can plot them.

Step 4: compare three catalog cuts

Add the reported false-alarm rate for the retained injection rows. Their original release indices link them to the same mass, redshift and draw density in the earlier table. The catalog replay uses the same denominator of generated injections at all three cuts because narrowing a cut changes which trials count as found.

.venv/bin/python observed_replay.py
shasum -a 256 outputs/o3b-observed-comparison.json

The catalog replay contains 23, 19 and 16 candidates at cuts of 1, 0.1 and 0.01 per year. At the first cut, the fit puts about 4.2% of source primaries above 30 solar masses, compared with 46.8% of the predicted detectable ones. Select the no-correction fit and the first share jumps to 43.8%. The catalog bars summarize each candidate's published mass posterior. The model lines average latent source masses over the joint hyperposterior, so this overlay shows the size of the selection effect without a formal goodness-of-fit test.

Step 5: run the injection-recovery test

.venv/bin/python injection_recovery.py
shasum -a 256 outputs/injection-recovery-results.json

It takes about 106 seconds and prints one line per row of the coverage table. Our fingerprint is 941662ac81619cbb7fcc851e7bbc6f8f2e5fbba3adfc6b2da6a42d8187ffc51c; our copy is outputs/injection-recovery-results.json. The synthetic events in this step are not detections: they are found injections resampled to a known population, α=3.5\alpha=3.5 and mmax⁡=70m_{\max}=70, each with a mock posterior. For 23-event catalogs with the selection term, the 68% and 90% coverages of α\alpha should come out as 0.61 and 0.91.

If your fingerprints differ, compare numbers before suspecting the method. Both scripts are seeded and reproduce byte for byte on the same NumPy build; a different build can change the last stored digits. Medians that agree to three significant figures mean you have reproduced the result.

Step 6: reproduce the failure cases

Each failure case below is stored in the failureCases block of the first output or in the second output. Reproducing them is part of the exercise, because each one marks a place where the method stops being trustworthy.

  1. No selection term. The withoutSelectionCorrection block gives α=0.26\alpha=0.26, pressed against the lower edge of the prior. The analysis has fitted the catalog instead of the universe.
  2. Too few injections. With 2000 found injections, Farr's condition Neff>4Nobs=92N_{\mathrm{eff}}>4N_{\mathrm{obs}}=92 first fails at α=4.25\alpha=4.25; with 500, at α=3.15\alpha=3.15, right at the upper end of the reported 90% interval. Farr, 2019
  3. An event the model can barely hold. GW191109_010717, with a primary near 65 solar masses, keeps only about 12 effective samples when mmax⁡m_{\max} is near 50. Look at perEventEffectiveAtPeak, then at posteriorMassInFlaggedCells.
  4. Samples beyond the injections. GW191127_050227 has 5.4% of its samples above 100 solar masses, where no injection was made and the model assigns zero density.
  5. A larger synthetic catalog. In the recovery output, 92-event catalogs cover only 0.83 at 90%, and most of their posterior mass sits in flagged cells.

Units, conventions and versions

  • Masses are source-frame solar masses with m1≥m2m_1\ge m_2. Redshift is dimensionless. The draw density in the injection file is a density in (m1,m2,z)(m_1,m_2,z) in those units.
  • The scripts use a flat cosmology with H0=67.74H_0=67.74 km/s/Mpc and Ωm=0.3089\Omega_m=0.3089. It reproduces the comoving distances stored with the parameter-estimation prior samples to about one part in 10410^4. The injection release documents a different flat cosmology, H0=67.9H_0=67.9 and Ωm=0.3065\Omega_m=0.3065; we use its stored draw densities directly, so that difference enters only through our population density.
  • The prior of the cosmological samples is πPE∝(1+z) dVc/dz\pi_{\mathrm{PE}}\propto(1+z)\,\mathrm dV_c/\mathrm dz in source-frame masses, as derived in the previous chapter.
  • The injection file read by the freeze step is endo3_bbhpop-LIGO-T2100113-v12-1256655642-12905976.hdf5. Because only 20 000 of its 39 069 found injections are kept, the number generated is scaled to 33 310 659×20 000/39 069≃1.705×10733\,310\,659\times20\,000/39\,069\simeq1.705\times10^7.

Where this analysis differs from GWTC-3

The GWTC-3 population paper counts an injection as found when PyCBC, GstLAL or MBTA recover it, and leaves out cWB. Abbott and colleagues, 2023, Appendix A Our freeze step counts an injection found in any of the five released searches, including cWB. It also uses only O3b events with O3b injections, a power law with no peak, a sharp edge at 5 solar masses and no spin model. These results show how the correction works for this restricted family and the O3b subset.

A checklist for your next population analysis

  • Which prior made the event samples, and have you divided by it in the same coordinates as your population?
  • What density were the injections drawn from, how many were generated, and which searches and threshold define found?
  • Is Farr's condition satisfied wherever the posterior has mass, not only at the peak?
  • Does every event keep enough effective samples across the grid, and how much posterior mass lies where one does not?
  • Does the model have support wherever the event samples do?
  • Does a known-population recovery test cover at the nominal rate for a catalog of your size?

Sources

  1. GWOSC tutorials
  2. GWTC-3 parameter-estimation release, Zenodo 5546663
  3. O3 search sensitivity release, Zenodo 5546676
  4. Farr, 2019
  5. Abbott and colleagues, 2023, Appendix A

Keep reading

What this page links to directly

See this series on the content map →

Gravitational-wave populations · Reading path

From a biased catalog to a corrected mass spectrum

  1. ArticleAre the black holes we detect a fair sample of the universe?
  2. ArticleDetection probability, redshifted mass and the pair-instability gap
  3. ArticleBuild a population model from mass, redshift and detector range
  4. ArticleHierarchical inference with selection effects on public GWTC-3 samples
  5. You are hereRecompute the black-hole mass spectrum from frozen GWTC-3 data
  6. ArticleWhat GW190521 says about the mass gap and repeated mergers
Something broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy