---
title: "用冻结的 GWTC-3 数据复算黑洞质量谱"
description: "下载冻结的后验样本和注入样本，重跑网格推断和注入回收检验，核对指纹并读懂失败案例。"
canonical_url: "https://sandboxphysics.com/zh/stories/gravitational-wave-populations/recompute-the-mass-spectrum-inference/"
language: "zh-CN"
page_type: "story"
alternate_languages:
  en: "https://sandboxphysics.com/stories/gravitational-wave-populations/recompute-the-mass-spectrum-inference/"
last_modified: "2026-11-14"
---

[引力波族群：质量间隙、配对与选择效应](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/)

# 用冻结的 GWTC-3 数据复算黑洞质量谱

Sandbox Physics · 2026-11-14

把漏掉的并合算进去，O3b 数据推得的质量谱会陡很多。用冻结的公开输入，你可以亲手跑出这个差别，再逐个检查方法容易失效的地方。用 Python 3.9.6、NumPy 2.0.2 和 SciPy 1.13.1。原始材料来自 GWTC-3 参数估计与 O3 搜索灵敏度数据。第一次接触这些文件，可以先翻 [GWOSC 教程](https://gwosc.org/tutorials/)。

[打开 O3b 星表对照](https://sandboxphysics.com/zh/labs/gravitational-wave-population-selection/#o3b-observed-comparison)

方法本身的推导在[带选择效应的分层推断](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/hierarchical-inference-with-selection/)一章。本页只讲怎样运行，以及怎样读结果。

## 材料文件夹里有什么

下面每个文件都由本站原样提供，SHA-256 指纹和[脚本说明](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/README.md)里写的一致。

**表 5.1** 输入文件。质量以太阳质量为单位（源系），红移无量纲。

| 文件 | 内容 | 来源 |
| --- | --- | --- |
| [inputs/o3b-bbh-posterior-samples.csv](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/inputs/o3b-bbh-posterior-samples.csv) | 23 个事件，每个 1500 个 $m_1$、$m_2$、$z$ 样本 | 真实数据：GWTC-3 C01:Mixed 宇宙学样本 |
| [inputs/o3b-bbh-found-injections.csv](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/inputs/o3b-bbh-found-injections.csv) | 20000 个已找到的注入，含 $m_1$、$m_2$、$z$ 和抽样密度 | 真实数据：O3b 双黑洞灵敏度注入 |
| [inputs/o3b-bbh-found-far.csv](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/inputs/o3b-bbh-found-far.csv) | 冻结的 20000 个注入各自的误报率 | LVK O3b 注入记录 |
| [inputs/frozen-subset-manifest.json](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/inputs/frozen-subset-manifest.json) | 事件标签、样本数、输入指纹、注入总数 | 冻结步骤写出 |
| [inputs/gwosc-gwtc3-confident-events.json](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/inputs/gwosc-gwtc3-confident-events.json) | 挑选事件时所用的 GWOSC 事件列表 | 真实数据：GWOSC 事件服务 |

两种数据产品都由 LIGO、Virgo 和 KAGRA 合作组以 CC BY 4.0 许可发布。[GWTC-3 parameter-estimation release, Zenodo 5546663](https://zenodo.org/records/5546663) [O3 search sensitivity release, Zenodo 5546676](https://zenodo.org/records/5546676)

脚本包括 [population\_model.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/population_model.py)（宇宙学、族群密度和参数估计先验）、[frozen\_inputs.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/frozen_inputs.py)（读取和指纹检查）、[hierarchical\_likelihood.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/hierarchical_likelihood.py)（网格上的事件项和选择项）、[hierarchical\_mass\_inference.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/hierarchical_mass_inference.py) 和 [injection\_recovery.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/injection_recovery.py)。冻结步骤 [freeze\_public\_subset.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/freeze_public_subset.py) 需要联网和 h5py，你不必运行它。

星表对照还用到 [observed\_replay.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/observed_replay.py) 和 [predictive\_mass.py](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/predictive_mass.py)。另有[误报率提取脚本](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/freeze_o3b_far.py)，需要原始 39.9 MB 注入文件。

## 第 1 步：下载并核对输入

```
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
```

屏幕上的三行 SHA-256 应与下面一致。

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

推断脚本运行前会再算一次 SHA-256。星表复算还会检查新增的 CSV。

## 第 2 步：准备环境

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

我们在 arm64 Mac 上用 Python 3.9.6、NumPy 2.0.2 和 SciPy 1.13.1 测试过。

## 第 3 步：运行网格推断

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

大约 0.3 秒跑完。我们这台机器上的指纹是 761339bd80c91b1933ad73ce5da0d8e9a90d34fc520acb1d1890cd64fd8424ec，我们的结果文件也已公开：[outputs/hierarchical-inference-results.json](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/outputs/hierarchical-inference-results.json)，可以拿来对照。先看修正后的后验：

```
"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
}
```

摘录里的数字做了舍入。alpha 是 $p(m_1)\propto m_1^{-\alpha}$ 的幂律斜率，mMax 是以太阳质量计的陡峭上限，90% 上下界来自网格上的边缘后验。文件里还存着两个边缘分布，可以直接画图。

## 第 4 步：换三个星表门槛

新增的 CSV 给每个冻结注入补上公开的误报率，行号仍指向同一组质量、红移和抽样密度。在更严的门槛下，找到的注入变少，生成过的试验总数则保留原值。

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

[星表复算结果](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/outputs/o3b-observed-comparison.json)给出三个门槛。误报率低于每年 1、0.1 和 0.01 次时，分别留下 23、19 和 16 个候选事件。先看最宽的门槛。校正漏检之后，源种群里约 4.2% 的主黑洞重于 30 个太阳质量，在预测可探测的并合里却占 46.8%。直接拟合星表，会把源种群里的比例推到 43.8%。柱形汇总各次事件公布的后验，曲线汇总种群模型中的潜在质量。两者放在一起，能读出选择效应有多大。

## 第 5 步：运行注入回收检验

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

大约 106 秒，覆盖率表每一行打印一行。我们的指纹是 941662ac81619cbb7fcc851e7bbc6f8f2e5fbba3adfc6b2da6a42d8187ffc51c，对应文件是 [outputs/injection-recovery-results.json](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/materials/outputs/injection-recovery-results.json)。这一步里的合成事件不是真实探测：它们是按已知族群（$\alpha=3.5$、$m_{\max}=70$）重新抽样的已找到注入，每个配一个模拟后验。23 个事件的星表在带选择项时，$\alpha$ 的 68% 和 90% 覆盖率应为 0.61 和 0.91。

如果指纹对不上，先比数字，再怀疑方法。两个脚本都固定了随机种子，在同一个 NumPy 构建上逐字节可复现；换一个构建，存下的最后几位数字可能不同。中位数在三位有效数字上一致，就说明你已经复现了结果。

## 第 6 步：复现失败案例

下面每个失败案例都存在第一个输出的 failureCases 部分，或者第二个输出里。沿着这些例子重跑，可以看到哪些输入会让结果失去支撑。

1. 没有选择项。withoutSelectionCorrection 部分给出 $\alpha=0.26$，贴在先验下边缘。分析拟合的是星表，而不是宇宙。
2. 注入太少。只用 2000 个已找到的注入时，Farr 条件 $N_{\mathrm{eff}}>4N_{\mathrm{obs}}=92$ 从 $\alpha=4.25$ 开始不满足；只用 500 个时，从 $\alpha=3.15$ 开始，正好在报告的 90% 区间上端。[Farr, 2019](https://arxiv.org/abs/1904.10879v1)
3. 模型勉强容得下的事件。GW191109\_010717 的主黑洞约 65 倍太阳质量；$m_{\max}$ 接近 50 时，它只剩约 12 个有效样本。先看 perEventEffectiveAtPeak，再看 posteriorMassInFlaggedCells。
4. 超出注入范围的样本。GW191127\_050227 有 5.4% 的样本高于 100 倍太阳质量，那里没有注入，模型给的密度为零。
5. 更大的合成星表。回收输出里，92 个事件的星表在 90% 水平只覆盖 0.83，大部分后验落在被标记的格点上。

## 单位、约定和版本

- 质量是源系太阳质量，$m_1\ge m_2$。红移无量纲。注入文件里的抽样密度，是在这些单位下 $(m_1,m_2,z)$ 的密度。
- 脚本用平直宇宙学，$H_0=67.74$ km/s/Mpc、$\Omega_m=0.3089$。它与参数估计先验样本中存的共动距离相差约万分之一。注入数据的说明文档用的是另一套平直宇宙学，$H_0=67.9$、$\Omega_m=0.3065$；我们直接使用文件里存好的抽样密度，所以这一差别只经由我们的族群密度起作用。
- 宇宙学样本在源系质量下的先验为 $\pi_{\mathrm{PE}}\propto(1+z)\,\mathrm dV_c/\mathrm dz$，推导见上一章。
- 冻结步骤读取的注入文件是 endo3\_bbhpop-LIGO-T2100113-v12-1256655642-12905976.hdf5。它的 39069 个已找到注入只保留了 20000 个，所以总生成数按 $33\,310\,659\times20\,000/39\,069\simeq1.705\times10^7$ 缩放。

## 和 GWTC-3 的不同之处

GWTC-3 族群论文把被 PyCBC、GstLAL 或 MBTA 找回的注入算作已找到，不计 cWB。[Abbott and colleagues, 2023, Appendix A](https://doi.org/10.1103/PhysRevX.13.011048) 我们的冻结步骤只要五个公开搜索中任何一个找到就算，包括 cWB。此外，我们只用 O3b 的事件和 O3b 的注入，幂律不带峰，5 倍太阳质量处是陡峭下限，也没有自旋模型。在这批 O3b 事件上，可以用它们读出漏检校正的影响。

## 下次做族群分析时的检查清单

- 事件样本是用什么先验生成的？你是否在与族群相同的坐标下除掉了它？
- 注入从什么密度中抽取，总共生成多少，“已找到”由哪些搜索和哪个阈值定义？
- 凡是后验有概率的地方，Farr 条件都满足吗？不能只看峰值。
- 每个事件在整个网格上都保有足够的有效样本吗？不满足的地方占了多少后验？
- 事件样本所在的地方，模型都有支撑吗？
- 对你这个规模的星表，已知族群的回收检验能达到名义覆盖率吗？

## 来源

1. [GWOSC 教程](https://gwosc.org/tutorials/)
2. [GWTC-3 parameter-estimation release, Zenodo 5546663](https://zenodo.org/records/5546663)
3. [O3 search sensitivity release, Zenodo 5546676](https://zenodo.org/records/5546676)
4. [Farr, 2019](https://arxiv.org/abs/1904.10879v1)
5. [Abbott and colleagues, 2023, Appendix A](https://doi.org/10.1103/PhysRevX.13.011048)

## 继续阅读

引力波族群 · 阅读路径

### 从有偏的星表到修正后的质量谱

1. [文章 **探测到的黑洞质量分布，等于宇宙里原来的分布吗**](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/are-detected-black-holes-a-fair-sample/)
2. [文章 **探测概率、红移质量与对不稳定性质量间隙**](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/detection-probability-and-the-mass-gap/)
3. [文章 **用质量、红移和探测距离搭起种群模型**](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/building-the-population-model/)
4. [文章 **给 GWTC-3 黑洞质量谱校正漏检**](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/hierarchical-inference-with-selection/)
5. [当前页面 **用冻结的 GWTC-3 数据复算黑洞质量谱**](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/recompute-the-mass-spectrum-inference/)
6. [文章 **从 GW190521 读质量间隙和重复并合**](https://sandboxphysics.com/zh/stories/gravitational-wave-populations/reading-gw190521-formation-channels/)
