pyhs3.likelihoods.Likelihood

class pyhs3.likelihoods.Likelihood(**data)[source]

Likelihood specification mapping distributions to observations.

Represents a likelihood function that combines parameterized distributions with observations to generate a likelihood function L(θ₁, θ₂, …). The likelihood is the product of PDFs evaluated at observed data points.

Variables:
  • name – Custom string identifier for the likelihood

  • distributions – Array of strings referencing distributions

  • data – Array of strings referencing data or inline values for constraints

  • aux_distributions – Optional array of auxiliary distributions for regularization

Parameters:

data (Any)

Fields

Field

Type

Required

Default

aux_distributions

list[str] | Distributions | None

No

None

data

list[str] | Data

Yes

distributions

list[str] | Distributions

Yes

name

str

Yes

Validators

Validator

Mode

Fields

validate_distributions_data_pairing

after

model

__init__(**data)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

Methods

binned_observed_inputs()

Binned data keyed by the {distribution}_observed input it supplies.

data_arrays()

Observable data as numpy arrays keyed by axis name.

distribution_names()

Names of the distributions this likelihood evaluates, auxiliary ones included.

validate_distributions_data_pairing()

Validate that distributions and data are properly paired.

validate_unique_axis_names([workspace])

Raise ValueError if any observable axis name appears more than once.

Attributes

Likelihood.binned_observed_inputs()[source]

Binned data keyed by the {distribution}_observed input it supplies.

A distribution paired with BinnedData (a HistFactory channel, for example) reads its observed bin counts from the input named {distribution}_observed. These inputs are data, not parameters.

Return type:

dict[str, BinnedData]

Likelihood.data_arrays()[source]

Observable data as numpy arrays keyed by axis name.

Returns a dict mapping each observable axis name to a 1-D float64 array of event values. Only data entries with both axes and entries are included (i.e. UnbinnedData).

Suitable for passing directly to compiled or JAX functions:

fn(**likelihood.data_arrays(), **params)
Return type:

dict[str, ndarray[tuple[Any, ...], dtype[float64]]]

Likelihood.distribution_names()[source]

Names of the distributions this likelihood evaluates, auxiliary ones included.

Return type:

list[str]

Likelihood.validate_distributions_data_pairing()[source]

Validate that distributions and data are properly paired.

Return type:

Likelihood

Likelihood.validate_unique_axis_names(workspace=None)[source]

Raise ValueError if any observable axis name appears more than once.

When workspace is provided, unresolved string FK references in data are resolved via workspace.data before checking. Without a workspace, string entries are skipped.

Parameters:

workspace (Workspace | None)

Return type:

None

Likelihood.distributions
Likelihood.data
Likelihood.aux_distributions
Likelihood.name