# _MainModel

class pyhf.pdf._MainModel(config, modifiers, nominal_rates, batch_size=None, clip_sample_data: = None, clip_bin_data: = None)[source]

Bases: `object`

Factory class to create pdfs for the main measurement.

__init__(config, modifiers, nominal_rates, batch_size=None, clip_sample_data: = None, clip_bin_data: = None)[source]

Methods

_precompute()[source]
expected_data(pars, return_by_sample=False)[source]

Compute the expected rates for given values of parameters.

For a single channel single sample, we compute:

Pois(d | fac(pars) * (delta(pars) + nom) ) * Gaus(a | pars[is_gaus], sigmas) * Pois(a * cfac | pars[is_poi] * cfac)

where:
• delta(pars) is the result of an apply(pars) of combined modifiers with ‘addition’ op_code

• factor(pars) is the result of apply(pars) of combined modifiers with ‘multiplication’ op_code

• pars[is_gaus] are the subset of parameters that are constrained by gauss (with sigmas accordingly, some of which are computed by modifiers)

• pars[is_pois] are the poissons and their rates (they come with their own additional factors unrelated to factor(pars) which are also computed by the finalize() of the modifier)

So in the end we only make 3 calls to pdfs

1. The pdf of data and modified rates

2. All Gaussian constraint as one call

3. All Poisson constraints as one call

has_pdf()[source]

Indicate whether the main model exists.

Returns:

Whether the model has a Main Model component (yes it does)

Return type:

Bool

logpdf(maindata, pars)[source]

Compute the logarithm of the value of the probability density.

Parameters:
• maindata (`tensor`) – The main channel data (a subset of the full data in a HistFactory model)

• pars (`tensor`) – The model parameters

Returns:

The log of the pdf value

Return type:

Tensor

make_pdf(pars)[source]
modifications(pars)[source]

Obtain the additive and multiplicative modifications to the expected event rates for the model parameters.

Parameters:

pars (`tensor`) – The model parameters

Returns:

• deltas (`list`) is the result of an `apply(pars)` of combined modifiers with `"addition"` `op_code`

• factors (`list`) is the result of `apply(pars)` of combined modifiers with `"multiplication"` `op_code`

Return type:

Tuple of additive and multiplicative modifications