pyhs3.distributions.histfactory.modifiers.HasConstraint

class pyhs3.distributions.histfactory.modifiers.HasConstraint[source]

Base class for modifiers that can have constraint terms.

__init__()

Methods

constraint_distribution(context, sample_data)

The constraint distribution and the context it evaluates in.

log_constraint(context, sample_data)

Create constraint term for this modifier (log space).

make_constraint(context, sample_data)

Create constraint term for this modifier (probability space).

unconstrained_parameters(sample_data)

Parameters that scale a positive yield but get no constraint term.

Attributes

abstractmethod HasConstraint.constraint_distribution(context, sample_data)[source]

The constraint distribution and the context it evaluates in.

The distribution’s x is the constraint’s global observable (auxiliary data), a constant of its own: of shape () for a single-parameter modifier and (B',) for a per-bin one, B' the number of constrained bins. Each call builds a new distribution and constant. None if the modifier constrains no parameter.

Parameters:
Return type:

tuple[SampleableDistribution, Context] | None

HasConstraint.log_constraint(context, sample_data)[source]

Create constraint term for this modifier (log space).

Log-space counterpart of make_constraint(): evaluates the same constraint distribution(s) via their analytic log_likelihood instead of taking pt.log of the probability-space result, so the constraint stays finite where the probability-space value would underflow to 0.0.

Parameters:
Return type:

TensorVar

HasConstraint.make_constraint(context, sample_data)[source]

Create constraint term for this modifier (probability space).

Parameters:
Return type:

TensorVar

HasConstraint.unconstrained_parameters(sample_data)[source]

Parameters that scale a positive yield but get no constraint term.

A per-bin parameter whose bin has a positive yield and zero uncertainty is left out of the constraint; pyhf and ROOT fix it at its nominal value, so it must be const. Modifiers with one constrained parameter have none.

Parameters:

sample_data (SampleData)

Return type:

list[str]

HasConstraint.constraint