Comparing Absolute NLL Values with RooFit

The negative log-likelihood -model.log_prob (see log_prob, which returns the log-likelihood) can differ from the value RooFit or quickFit reports for the same workspace and dataset. The difference is a constant that does not depend on any parameter. pyhs3 keeps its convention in both cases below, and this page explains where each constant comes from so you can reconcile absolute values.

Fits, profile scans, and \(\Delta\mathrm{NLL}\) intervals are unaffected: a constant added to the NLL moves the minimum’s value, not its location or the difference between two points. Only a comparison of absolute NLL values sees the offset.

Simultaneous distributions over several channels

RooFit’s RooSimultaneous treats the index category as an observable and normalizes over the observable x and the category idx together. With channel densities \(f_c(x)\) that each integrate to one over x, the normalization is

\[Z = \sum_{c} \int f_c(x)\,\mathrm{d}x = n_\text{channels},\]

so RooFit’s density is \(p(x, c) = f_c(x) / n_\text{channels}\). Each event contributes an extra \(\ln n_\text{channels}\) to RooFit’s NLL:

\[\mathrm{NLL}_\text{RooFit} = \mathrm{NLL}_\text{pyhs3} + W \ln n_\text{channels},\]

where \(W\) is the sum of the event weights of the dataset. \(W\) is the weighted sum, not the number of entries: an entry with weight \(10^{-9}\) adds almost nothing, so RooFit padding or “ghost” entries barely change \(W\). For example, \(W = 642\) across 14 channels gives \(642 \ln 14 \approx 1694.3\).

pyhs3 does not apply this normalization because the combined distribution of the HS3 specification is a plain product over its channels. Its category keys “introduce no variable or observable”, so nothing in the likelihood encodes a channel count to divide by. See the combined distribution in the HS3 composite distributions chapter.

Extended unbinned data

For an extended unbinned distribution with \(N\) events and expected yield \(\nu\), the HS3 specification writes the event-count term as \(\mathrm{Poisson}(N \mid \nu)\), which contains \(-\ln N!\) in the log-likelihood. pyhs3 omits that term, as RooFit does. An extended mixture contributes \(\sum_j \ln \sum_i c_i f_i(x_j) - \nu\) (see pyhs3.distributions.MixtureDist.log_prob_terms()), so the pyhs3 NLL is smaller than the specification’s literal form by \(\ln N!\) per extended unbinned dataset. This constant is the same one RooFit omits, so it does not add to the RooFit offset above.

The specification does not yet state whether omitting the term is allowed. The proposal to allow it is hep-statistics-serialization-standard PR #164, which follows issue #91.

Weighted data enters as \(\sum_k w_k \ln f(x_k)\), without dividing by \(\sum_k w_k\), which matches RooFit’s weighted NLL.

To compute an NLL to compare against a RooFit value, see Evaluate a Model’s PDF and Log-PDF.