spey.backends.default_pdf.simple_pdf.SimplePDFBase

spey.backends.default_pdf.simple_pdf.SimplePDFBase#

class spey.backends.default_pdf.simple_pdf.SimplePDFBase(signal_yields: List[float] | Callable[[ndarray], ndarray], background_yields: List[float], data: List[int], n_signal_parameters: int = 0, signal_parameter_bounds: List[Tuple[float | None, float | None]] | None = None)[source]#

Abstract base class for nuisance-free (simple) PDF backends.

Subclasses implement statistical models in which the expected bin counts depend only on the signal strength \(\mu\),

\[\lambda_i(\mu) = \mu\, n^s_i + n^b_i,\]

with no systematic nuisance parameters entering the fit (or, in the case of Poisson with absolute_uncertainties, unconstrained nuisances that are marginalised by the optimiser without an explicit constraint model).

This class provides:

  • Common storage and autograd-compatible array initialisation.

  • Minimum-POI computation: \(\mu_{\min} = -\min_{i} n^b_i / n^s_i\) over bins with \(n^s_i > 0\).

  • A lazily-initialised main_model property based on the \(\lambda(\mu)\) function above.

  • Default implementations of get_objective_function(), get_logpdf_func(), get_hessian_logpdf_func(), get_sampler(), and expected_data() that all delegate to main_model.

Subclasses customise the model by overriding main_model (by setting self._main_model directly in __init__) and by passing self._main_kwargs to change the distribution type used by MainModel.

__init__(signal_yields: List[float] | Callable[[ndarray], ndarray], background_yields: List[float], data: List[int], n_signal_parameters: int = 0, signal_parameter_bounds: List[Tuple[float | None, float | None]] | None = None)[source]#

Methods

__init__(signal_yields, background_yields, data)

asimov_negative_loglikelihood([poi_test, ...])

Compute the profiled negative log-likelihood at fixed \(\mu\) on Asimov data.

combine(other, **kwargs)

Combine this statistical model with another backend instance.

config([allow_negative_signal, poi_upper_bound])

Model configuration.

expected_data(pars, **kwargs)

Compute the expected data vector \(\{\lambda_i(\mu)\}\) at the given parameter point.

get_hessian_logpdf_func([expected, data])

Return a callable that evaluates the Hessian of \(\ln\mathcal{L}(\mu)\).

get_logpdf_func([expected, data])

Return a callable that evaluates \(\ln\mathcal{L}(\mu)\).

get_objective_function([expected, data, do_grad])

Return the objective function \(-\ln\mathcal{L}(\mu)\) used by the optimiser.

get_sampler(pars)

Return a callable that draws pseudo-data from the main model.

minimize_asimov_negative_loglikelihood([...])

Find the global minimum of the negative log-likelihood on Asimov data (free fit).

minimize_negative_loglikelihood([expected, ...])

Find the global minimum of the negative log-likelihood (free fit).

negative_loglikelihood([poi_test, expected])

Compute the profiled negative log-likelihood at a fixed \(\mu\).

Attributes

data

signal_yields

background_yields

author

Author of the backend

is_alive

Returns True if at least one bin has non-zero signal yield.

main_model

Main model distribution — Poisson (or Gaussian) term of the likelihood.

name

Name of the backend

spey_requires

Spey version required for the backend

version

Version of the backend

constraints

Constraints to be used during optimisation process

n_signal_parameters

Number of signal parameters