How brutus works

brutus infers the distance, extinction and properties of a star from its photometry and, if available, its parallax [Speagle et al., 2025]. It does not run a sampler. It evaluates every model in a grid of stellar models, integrates the priors for each one, and builds the posterior as a weighted sum over models.

The four steps of a brutus fitEvery grid model is fitted for distance and dust; the good fits are kept; for each, Monte Carlo draws in log-distance and dust are weighted by the priors; the posterior is the weighted sum over models.1 Fit every modelmass, age, metallicitybest distance and dust each2 Keep the good fitswithin 10⁻³ of the best3 Integrate the priorslog distance →draws in pairs (z, −z),weighted by the priors4 Draw the posteriordistance →the sum over models;250 draws are saved

The four steps of a fit, described in The fit in four steps.

The forward model

A model star has intrinsic parameters \(\theta\), which set its spectral energy distribution (SED), and extrinsic parameters \(\phi\), which set how it appears to us:

Parameter

Meaning

\(\theta\)

\(M_{\rm init}\)

initial mass, in \(M_\odot\)

EEP

equivalent evolutionary point: the position along the evolutionary track

[Fe/H]

metallicity

\(\phi\)

\(d\)

distance

\(A_V\)

extinction in the V band, in mag

\(R_V\)

shape of the extinction curve

Age is not a parameter: it follows from \((M_{\rm init}, {\rm EEP}, {\rm [Fe/H]})\). Stellar models explains the tracks and why EEP is used.

Each grid model stores its magnitudes \(M_b(\theta)\) in every band \(b\) at a distance of 1 kpc, and two reddening vectors \(R_b(\theta)\) and \(R'_b(\theta)\). The predicted flux in band \(b\) is

\[F_b(\theta, \phi) = s \; 10^{-0.4\,\left[ M_b(\theta) + A_V \left( R_b(\theta) + R_V\, R'_b(\theta) \right) \right]}, \qquad s = \left( \frac{1\,{\rm kpc}}{d} \right)^2 ,\]

where \(s\) is the scale factor. Distance dims all bands by the same factor; dust dims blue bands more than red ones. The extinction curve follows Fitzpatrick and Massa [2009], with \(R_V\) as its shape parameter.

The forward modelA model SED at 1 kpc is scaled to the distance of the star and dimmed by dust, which dims blue bands more than red ones, and compared with the observed photometry.wavelengthbrightnessgrizyJHKsmodel SED at 1 kpcmoved to distance ddimmed by dust; datascale = (1 kpc / d)²dust: most in blue

The likelihood

brutus compares fluxes, not magnitudes, because flux errors are close to Gaussian and magnitude errors are not. For the observed fluxes \(\hat F_b\) with errors \(\sigma_b\), over the \(N_b\) valid bands,

\[\chi^2(\theta, \phi) = \sum_{b=1}^{N_b} \frac{\left( \hat F_b - F_b(\theta, \phi) \right)^2}{\sigma_b^2}, \qquad \ln \mathcal{L}_{\rm phot} = -\tfrac{1}{2}\,\chi^2 + \text{normalization}.\]

The normalization holds the Gaussian terms in \(\sigma_b\) and, by default, a term in the number of bands (logl_dim_prior), so that stars with different numbers of bands are weighted consistently.

A parallax \(\hat\varpi \pm \sigma_\varpi\), in mas, adds a Gaussian term in \(\varpi = 1/d\) with \(d\) in kpc:

\[-2 \ln \mathcal{L}_\varpi(d) = \frac{\left( \hat\varpi - 1/d \right)^2}{\sigma_\varpi^2} + {\rm const}.\]

A fit needs at least 4 bands: each model has 3 free parameters (\(s\), \(A_V\), \(R_V\)).

The priors

The model prior depends only on the grid model; the position-dependent priors depend on where the star is; the \(R_V\) prior is the same for all stars.

\[\pi(\theta, \phi) = \underbrace{\pi_{\rm IMF}(M_{\rm init}) \; \frac{dt}{d\,{\rm EEP}} \; \Delta V(\theta)}_{\text{model prior}} \;\times\; \underbrace{\pi_{\rm gal}(d, \theta \mid \ell, b) \; \pi_{\rm dust}(A_V \mid d, \ell, b)}_{\text{position-dependent priors}} \;\times\; \pi(R_V)\]
  • Initial mass function: the Kroupa [2001] IMF.

  • Age weight \(dt/d\,{\rm EEP}\): the time a star spends per unit of EEP. It turns a prior uniform in EEP into one uniform in age.

  • Grid volume \(\Delta V\): the spacing of the grid in each parameter, so that a sum over models approximates an integral. The default grid steps EEP by 6 on the main sequence and by 2 after it.

  • Galactic structure \(\pi_{\rm gal}\): the density of a thin disk, a thick disk and a halo along the sightline \((\ell, b)\), each with its own metallicity distribution and an age distribution set by that metallicity.

  • Dust map \(\pi_{\rm dust}\): the Bayestar 3D dust map [Green et al., 2019], if given, with 0.2 mag of scatter added to the map’s own spread. Where the map has no reliable value, this prior is uniform in \(A_V\).

  • Extinction curve \(\pi(R_V)\): Gaussian with mean 3.32 and standard deviation 0.18 [Schlafly et al., 2016]. It enters the fit of each model in step 1, and so the Gaussian that step 3 draws from, and its value at the fit enters the model’s weight.

Priors gives each prior’s equation, defaults and function.

The fit in four steps

1. Fit every model. For each grid model, brutus finds the \((s, A_V, R_V)\) that maximize \(\mathcal{L}_{\rm phot}\,\pi(R_V)\) by Gauss-Newton iteration: first in magnitudes for every model, then in fluxes for the models whose magnitude-space fit is close to the best. It also computes their 3×3 Fisher matrix, which describes a Gaussian around the best fit.

2. Choose the models. Each model gets a selection weight: its posterior weight of step 3, with the priors at its best fit \((\hat d, \hat A_V)\) in place of their average,

\[\mathcal{L}_{\rm phot}\,\pi_{\rm model}\,|2\pi\Sigma|^{1/2}\;\pi_{\rm gal}(\hat d, \theta)\;\pi_{\rm dust}(\hat A_V \mid \hat d)\;\hat d.\]

\(\Sigma\) is the covariance of the model’s Gaussian in \((\ln d, A_V, R_V)\) (step 3). brutus interpolates the default Galactic prior from a table along the sightline, in distance, [Fe/H] and age. If a parallax is given, the weight is multiplied by the parallax likelihood averaged over the model’s Gaussian in \(\ln d\): \(\int \mathcal{N}(\ln d)\,\mathcal{N}(\varpi \mid 1/d,\,\sigma_\varpi)\,d\ln d\). Its width is the uncertainty of \(\ln d\) after marginalizing over \(A_V\) and \(R_V\). A five-node Gauss-Hermite rule, centred on the peak of the integrand, evaluates it for every model.

brutus then keeps 5,000 models (max_models) at random. Model \(i\) is kept with probability \(p_i = \min(1, c\,w_i)\), proportional to its selection weight \(w_i\), and its posterior weight in step 4 is divided by \(p_i\). This keeps the evidence and the posterior draws unbiased for any selection weight. The closer the selection weight is to the posterior weight, the smaller their scatter.

3. Integrate the priors. For each kept model \(i\), brutus draws \(N_{\rm mc} = 50\) points from its Gaussian in \((\ln d, A_V, R_V)\), in antithetic pairs \((z, -z)\). Each point \(j\) is weighted by the priors that depend on position and by the exact parallax likelihood. The model’s posterior weight is the average:

\[w_i \;\propto\; \mathcal{L}_{{\rm phot},i}\, \pi_{{\rm model},i}\, |2\pi\Sigma_i|^{1/2} \; \frac{1}{N_{\rm mc}} \sum_{j=1}^{N_{\rm mc}} \pi_{\rm gal}(d_{ij}, \theta_i)\; \pi_{\rm dust}(A_{V,ij} \mid d_{ij})\; \mathcal{L}_\varpi(d_{ij})\; d_{ij}.\]

\(\Sigma_i\) is the covariance of the model’s Gaussian, so \(\mathcal{L}_{{\rm phot},i}\,|2\pi\Sigma_i|^{1/2}\) is the Laplace approximation of the likelihood integrated over \((\ln d, A_V, R_V)\). A model whose fit is less tightly constrained covers more of that space and weighs more. The factor \(d_{ij}\) is the Jacobian of sampling in \(\ln d\). Sampling in \(s\) instead would bias distances by a factor \(d^{-3}\).

A model’s points span only 0.01 to 0.03 in \(\ln d\) for most stars, because its absolute magnitude fixes its distance, so the default \(\pi_{\rm gal}\) is smooth across them. brutus evaluates it at 5 Chebyshev nodes over that range and interpolates it to the points. Where that interpolant differs by more than \(10^{-3}\) in \(\ln \pi_{\rm gal}\) from the one through 3 of the nodes, brutus uses 9 nodes, and where 9 fail the same check, it evaluates the prior at every point.

The parallax is used three times. During step 1, models whose magnitude-space fit, with the parallax added at the best-fit \(s\), is more than a factor \(10^6\) worse than the best (logl_initthresh) keep that fit and are not refined. The averaged term in step 2 then sets the probability that each model is kept. Only the exact term here sets the weights.

4. Draw the posterior. brutus draws 250 models (Ndraws) in proportion to the posterior weight \(w_i\) of step 3, divided by \(p_i\) for the models kept by max_models, and for each one draws a point \((d, A_V, R_V)\) from its weighted Monte Carlo points. These are the saved posterior draws.

Why the parallax matters

Dust reddens a star as well as dimming it, so the colours measure the dust, but only as well as they measure the star’s temperature. A hotter star behind more dust has nearly the same colours as a cooler star behind less. On the main sequence the hotter star is also more luminous, so it lies farther away. Photometry alone therefore allows a nearer, less reddened star or a farther, more reddened one. A parallax limits the distance directly, and the posterior is where the two agree.

The distance-extinction degeneracyPhotometry alone allows a nearer, less reddened star or a farther, more reddened one. A parallax limits the distance, and the posterior is where both agree.distanceextinction A(V)photometry alone: nearer andless reddened, or farther and moreparallax: a rangeof distanceboth: the posterior

Without a parallax, the Galactic and dust priors set where along this degeneracy the posterior lies.

What brutus returns

For each star, the output file holds the posterior draws of distance, \(A_V\) and \(R_V\), the grid model of each draw (from which mass, age, temperature and the other properties follow), and fit diagnostics: the best \(\chi^2\), the number of bands, and the log-evidence. Understanding results describes each field.

An example: a sightline towards Orion

The tutorials include 207 stars in one small field towards Orion (\(\ell = 209.1°\), \(b = -19.9°\)), with Pan-STARRS and 2MASS photometry and Gaia parallaxes. Fitted with the default grid and priors, the stars that fit well trace the dust along the sightline: their extinction is low out to about 0.4 kpc and, with scatter, rises to 2 to 5 mag beyond 0.5 kpc, behind the Orion molecular cloud.

Distances and extinctions of stars towards OrionPosterior draws and medians of distance and extinction for 92 well-fitted stars within 2.5 kpc towards l = 209.1, b = -19.9. Extinction is low out to about 0.4 kpc and rises, with scatter, to 2 to 5 mag beyond 0.5 kpc, behind the Orion molecular cloud.distance (kpc)extinction A(V) (mag)0.511.522.50246mediandraws92 stars,p > 0.001,d < 2.5 kpc

Distance and extinction of the stars with p-value above \(10^{-3}\) (Understanding results) and median distance below 2.5 kpc, without a dust-map prior. Each star contributes 25 posterior draws and its median.

Fitting a dust profile to many such posteriors is how brutus maps dust in 3D; tutorial 7 shows it.

Assumptions

  • Single stars. The default grid has no unresolved binaries. A binary looks too bright, so its distance comes out too small.

  • Non-rotating, solar-scaled MIST models [Choi et al., 2016, Dotter, 2016]. Fast rotators and chemically peculiar stars are not modelled.

  • One extinction curve family, with \(R_V\) free within its prior.

  • Systematic differences between models and data remain at the level of a few hundredths of a magnitude per band. Photometric offsets describes the corrections and how to add their uncertainties to the errors.

For faint stars without a parallax, the result depends on the priors. Check how the result changes with them for your science case.