---
title: "Fitting GW170817 and the trade-off between ejecta mass and speed"
description: "Write the likelihood with an extra scatter term, compare one- and two-component fits to GW170817, and map why mass and speed trade off."
canonical_url: "https://sandboxphysics.com/stories/kilonovae/fitting-gw170817-and-parameter-degeneracy/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/kilonovae/fitting-gw170817-and-parameter-degeneracy/"
last_modified: "2026-11-14"
---

[Kilonovae: heavy elements and diffusing light](https://sandboxphysics.com/stories/kilonovae/)

# Fitting GW170817 and the trade-off between ejecta mass and speed

Sandbox Physics · 2026-11-14

Fitted to 394 measurements of GW170817, the two-component grey model reaches a root-mean-square residual of $0.29$ magnitudes once an extra scatter of $0.26$ magnitudes is allowed, and a single component does far worse. The data fix each component's diffusion time better than its mass or speed: the red mass and speed are correlated at $0.89$ and slide along a valley of nearly constant $M/v$. This chapter writes down the likelihood, compares five fits and maps that valley.

[Open the kilonova light-curve Lab](https://sandboxphysics.com/labs/kilonova-light-curves/)

It uses the model of [from the energy equation to kilonova light curves and colours](https://sandboxphysics.com/stories/kilonovae/arnett-light-curves-and-the-photosphere/). The step-by-step commands are in [reproducing a two-component kilonova fit to the GW170817 photometry](https://sandboxphysics.com/stories/kilonovae/reproducing-a-two-component-fit-to-gw170817/).

## The data

Villar and colleagues combined 647 measurements from 18 papers and 46 instruments into one table, corrected for offsets between datasets, and marked outliers. [Villar and colleagues, §2 and Table 3](https://arxiv.org/abs/1710.11576v2) We keep the detections in $g$, $r$, $i$, $z$, $J$, $H$ and $K$ or $K_s$ that they used in their own fit and did not flag as outliers. That leaves 394 points from $0.45$ to $25.4$ days, with $r$ the best covered band at 83 points and $J$ the sparsest at 38.

The magnitudes are not corrected for dust in the Milky Way. Instead the model adds extinction, $A_\lambda=R_\lambda E(B-V)$ with $E(B-V)=0.1228$ and the coefficients for $R_V=3.1$. [Schlafly and Finkbeiner, Table 6](https://arxiv.org/abs/1012.4804v2) The distance is fixed at $39.5\,\mathrm{Mpc}$.

## The likelihood

Each point $i$ has an observed magnitude $O_i$, an error $\sigma_i$ and a model value $M_i$. The model is too simple to match every point within its error: real filters are broad while the model uses one wavelength per band, the spectrum is not a blackbody, and instruments still differ slightly. Villar and colleagues therefore add an unknown scatter $\sigma$ in quadrature. [Villar and colleagues, §3.2, eq. 6](https://arxiv.org/abs/1710.11576v2) We use the normalised Gaussian form

$$
-\ln\mathcal L=\frac12\sum_{i=1}^{n}\left[\frac{(O_i-M_i)^2}{\sigma_i^2+\sigma^2}+\ln\bigl(2\pi(\sigma_i^2+\sigma^2)\bigr)\right].
$$

Their printed equation keeps $\ln(2\pi\sigma_i^2)$ inside the sum with the opposite sign and a separate $-(n/2)\ln(2\pi\sigma^2)$ outside it. That is not the normalisation of a Gaussian with variance $\sigma_i^2+\sigma^2$, so we use the form above and record the difference.

The fit maximises $\mathcal L$ rather than sampling it as Villar and colleagues did. With $k$ free parameters, the Bayesian information criterion

$$
\mathrm{BIC}=2(-\ln\mathcal L)+k\ln n
$$

penalises extra freedom. A difference above about $10$ is strong evidence for the lower value.

## What is free and what is fixed

The blue opacity is fixed at $0.5\,\mathrm{cm^2\,g^{-1}}$, as in Villar and colleagues' two-component model. The free parameters are the blue mass, speed and floor temperature, the red mass, speed, floor and opacity, and the scatter: eight in all.

The likelihood has several local maxima. The script starts the optimiser from many points and keeps all distinct solutions.

**Table 3.1** Distinct local optima of the two-component fit.

| $-\ln\mathcal L$ | Blue $M$, $v$ | Red $M$, $v$, $\kappa$ | $\sigma$ |
| --- | --- | --- | --- |
| $63.02$ | $0.0209$, $0.385$ | $0.0525$, $0.152$, $3.18$ | $0.261$ |
| $64.90$ | $0.0178$, $0.387$ | $0.0501$, $0.198$, $2.63$ | $0.245$ |
| $82.13$ | $0.0231$, $0.282$ | $0.0460$, $0.139$, $3.31$ | $0.277$ |
| $137.28$ | $0.0204$, $0.299$ | $0.0385$, $0.116$, $1.82$ | $0.302$ |

The third row lies close to Villar and colleagues' published values: $0.023$, $0.256$ for blue and $0.050$, $0.149$, $3.65$ for red. [Villar and colleagues, Table 2](https://arxiv.org/abs/1710.11576v2) Our best solution prefers a faster blue component, $0.385c$, which lies beyond the largest speed, $0.3c$, in the thermalization table, so its thermalization uses the table's edge values. That blue speed is best read as a property of this simplified model.

## Comparing models

**Table 3.2** Five fits to the same 394 points.

| Model | $k$ | $\sigma$ | $-\ln\mathcal L$ | BIC |
| --- | --- | --- | --- | --- |
| Two components | $8$ | $0.261$ | $63.02$ | $173.85$ |
| Red opacity fixed at $10$ | $7$ | $0.366$ | $178.94$ | $399.71$ |
| No floor, $T_c=300\,\mathrm K$ | $6$ | $0.399$ | $243.13$ | $522.12$ |
| One component | $5$ | $0.546$ | $332.93$ | $695.74$ |
| Villar values, our setup | $1$ | $0.293$ | $106.32$ | $218.62$ |

One grey component cannot make an early blue peak and a late infrared plateau at the same time; its BIC is worse by $522$. Removing the temperature floors costs $348$. Forcing the red opacity to $10$, a value typical of lanthanide-rich matter, costs $226$: these data prefer an intermediate opacity near $3$. Villar and colleagues' published parameters, plugged into our code with only $\sigma$ refitted, are worse than our optimum by $43$ in $-\ln\mathcal L$ and leave the late $K$ band about $0.20$ magnitudes too bright. Differences in data selection, likelihood normalisation and sampling can each contribute; we have not separated them.

The best fit is not perfect. Its worst band is $H$, with an rms residual of $0.40$ magnitudes. Villar and colleagues found that their two-component model predicts a double-peaked $K$ light curve that the data do not show, one reason they preferred three components. [Villar and colleagues, Fig. 5](https://arxiv.org/abs/1710.11576v2)

## Why mass and speed trade off

The diffusion time depends on $M$ and $v$ only through $M/v$:

$$
t_d=\sqrt{\frac{2\kappa M}{\beta vc}} .
$$

Raise both by the same factor and the light curve's timescale stays put. Two other things change, but more weakly: the photosphere is larger at fixed time, $R=vt$, so the same luminosity comes out cooler, and the thermalization fraction shifts. The data feel these second-order effects only faintly.

**Table 3.3** Profile of $-\ln\mathcal L$ over red mass and speed, the other parameters re-fitted, minus the grid minimum $63.98$.

| $M$ \\ $v$ | $0.13$ | $0.15$ | $0.16$ | $0.17$ | $0.20$ |
| --- | --- | --- | --- | --- | --- |
| $0.045$ | $8.8$ | $22.3$ | $15.7$ | $9.6$ | $22.4$ |
| $0.050$ | $25.1$ | $0.2$ | $8.7$ | $22.4$ | $2.1$ |
| $0.055$ | $63.4$ | $4.0$ | $0.0$ | $7.5$ | $10.4$ |
| $0.060$ | $119.8$ | $27.2$ | $8.2$ | $4.1$ | $36.7$ |

The low values run diagonally: $(0.050, 0.15)$, $(0.055, 0.16)$, $(0.060, 0.17)$, all with $M/v$ near $0.34$. A second, shallower branch appears near $v=0.20$. For two parameters, a rise of $1.15$ in $-\ln\mathcal L$ bounds a joint $68$ percent region and a rise of $3.0$ a $95$ percent region. The point at $v=0.20$ is excluded at $68$ percent but not at $95$ percent.

The local error estimate from the curvature at the best fit gives $\pm0.0022$ in red mass and $\pm0.0052$ in red speed, with correlation $0.888$. Those numbers describe the bottom of one valley. They miss the second branch, and they would understate the uncertainty if quoted alone.

## Shape and viewing angle

All of this assumes spherical components. Villar and colleagues also fitted a three-component model with the blue component confined near the poles, weighting the components by $1-\cos\theta$ and $\cos\theta$. It gave a half-opening angle $\theta=66^{+1}_{-3}$ degrees and masses about half those of the spherical fit. [Villar and colleagues, §3.1 and §4](https://arxiv.org/abs/1710.11576v2) They treated those parameters as a guide to the effect of asymmetry, and ours deserve the same caution: the mass of a kilonova inferred from photometry depends on its assumed shape.

## Lab tasks

1. Lower the red mass to $0.045$ and the red speed to $0.134$. Check that the red diffusion time stays at $7.36$ days, and estimate by eye how far the $K$ curve moves.
2. From the default, change only the red speed to $0.134$. The diffusion time now changes. Compare the shift in the $K$ curve with task 1.
3. Set the red opacity to $10$. Which bands move away from the points, and in which direction?

## Exercises with explained answers

1. Check the BIC of the two-component fit from $-\ln\mathcal L=63.02$, $k=8$ and $n=394$.
2. Red mass and speed lie along $M/v\approx0.34$. If the red speed were $0.18$, what mass would keep the diffusion time unchanged?
3. A colleague quotes the red mass as $0.0525\pm0.0022$ solar masses. What would you add?
4. Why can a larger extra scatter $\sigma$ make $-\ln\mathcal L$ smaller even though it widens every error bar?

Answers

1. $2\times63.02+8\ln394=126.04+8\times5.976=173.85$, as in Table 3.2.
2. $M\approx0.34\times0.18=0.061$ solar masses, at fixed red opacity. The profile table shows this region is not favoured by the data, because the second-order effects grow away from the best fit.
3. That the error is the local curvature at one optimum. Along the diagonal valley, and on the second branch near $v=0.20$, other masses fit almost as well; the value also depends on the spherical, grey model and would drop by about half for the polar geometry Villar and colleagues tried.
4. Each term has two parts. The squared residual divided by the variance falls as $\sigma$ grows, while $\ln(\sigma_i^2+\sigma^2)$ rises. When residuals are larger than the quoted errors, the first effect wins until $\sigma$ roughly matches the typical residual. Here that balance sits at $0.26$ magnitudes, close to the rms residual of $0.29$.

Repeat the fit yourself, with every input and failure case, in [reproducing a two-component kilonova fit to the GW170817 photometry](https://sandboxphysics.com/stories/kilonovae/reproducing-a-two-component-fit-to-gw170817/).

## Try it in the Lab

Lower the red mass to 0.045 and the red speed to 0.134. The red diffusion time in the caption stays at 7.36 days, and the K curve moves by about a tenth of a magnitude. [Open the kilonova light-curve Lab](https://sandboxphysics.com/labs/kilonova-light-curves/)

## Sources

1. [Villar and colleagues, §2 and Table 3](https://arxiv.org/abs/1710.11576v2)
2. [Schlafly and Finkbeiner, Table 6](https://arxiv.org/abs/1012.4804v2)

## Keep reading

Kilonovae: heavy elements and diffusing light · Reading path

### From radioactive heat to a blue-then-red flash

1. [Article **How does a neutron-star collision turn nuclear decay into days of coloured light?**](https://sandboxphysics.com/stories/kilonovae/why-a-kilonova-turns-from-blue-to-red/)
2. [Article **Radioactive heat and the time light needs to escape merger debris**](https://sandboxphysics.com/stories/kilonovae/heating-and-diffusion-in-merger-debris/)
3. [Article **From the energy equation to kilonova light curves and colours**](https://sandboxphysics.com/stories/kilonovae/arnett-light-curves-and-the-photosphere/)
4. [You are here **Fitting GW170817 and the trade-off between ejecta mass and speed**](https://sandboxphysics.com/stories/kilonovae/fitting-gw170817-and-parameter-degeneracy/)
5. [Article **Reproducing a two-component kilonova fit to the GW170817 photometry**](https://sandboxphysics.com/stories/kilonovae/reproducing-a-two-component-fit-to-gw170817/)
6. [Article **Reading Tanaka et al. 2020 on r-process opacities in kilonovae**](https://sandboxphysics.com/stories/kilonovae/reading-tanaka-2020-kilonova-opacities/)
