Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Making a Pull Plot

Let’s use a background-only workspace that we’ve bundled with the tutorial. It’s a little bit more complicated than the simple workspace we’ve seen in the past, but it will be a bit easier to demonstrate the efficacy of pulls this way.

Loading the workspace

Model and Data

Making a Pull Plot

We need to use minuit in order to perform the fits. So first we’ll set our backends to use numpy and minuit. Then we’ll do a bunch of setup to make it easier to compute the pulls. Work is on-going in pyhf to streamline this a bit more and put it into pyhf.contrib.

Unlike the scipy optimizer, minuit provides the uncertainties on the parameters which we need for the pulls.

Note: one really nice feature that we love about the backend switching is you can also customize the backends instead of using a default config... such as changing the tolerance.

Performing the Fit

In the past, we’ve done a hypothesis test which does multiple fits, both constrained and unconstrained fits. Instead, we will need to perform an unconstrained fit on the background in order to determine the fluctuation of all the parameters and the corresponding pulls.

With return_uncertainties=True, we return, instead of just a 1-dimensional vector of the fitted parameter values, a 2-dimensional vector including the fitted parameter uncertainties as well.

So let’s split this up to handle.

Normalize to natural width

Now we need to compute the pulls. In order to do so, we need to determine the constrained parameters of the model. We can do this by looping over the ordered parameters of the model. pyhf maintains a particular order of the parameters as we load them up into a large tensor in a specific order. So we can access this same order of the fitted parameters to the parameter names using pyhf.Model.config.par_order:

So first, we’ll compute the pulls. This is done by calculating the difference between the fitted parameter value, the initial value, and divide by the width of that constrained parameter

pull=χ^−χσ\text{pull} = \frac{\hat{\chi} - \chi}{\sigma}

We can also do this similarly for the error on the parameter as well:

Finally, we just need to create a set of labels for the parameters that were constrained that we are showing pulls for.

Order Results

Now we need to sort the labels in order of the uncertainty to make things easier to digest. We’ll figure out the sort order we need using np.argsort and apply that ordering to everything we’ve created.

Plotting Results

Now we can finally make a plot to appease our supervisor!