spey.backends.default_pdf.UncorrelatedBackground#
- class spey.backends.default_pdf.UncorrelatedBackground(signal_yields: List[float] | Callable[[ndarray], ndarray], background_yields: List[float], data: List[int], absolute_uncertainties: List[float], modifiers: List[Dict[str, Any]] | None = None, n_signal_parameters: int = 0, signal_parameter_bounds: List[Tuple[float | None, float | None]] | None = None)[source]#
Single- or multi-bin simplified likelihood with uncorrelated background uncertainties (
default.uncorrelated_background).Each bin is assigned its own independent Gaussian nuisance parameter \(\theta_i\), scaled by the absolute background uncertainty \(\sigma_i\). The full likelihood is
\[\mathcal{L}(\mu, \boldsymbol{\theta}) = \prod_{i=1}^{N} \mathrm{Poiss}\!\left(n^{\rm obs}_i \,\Big|\, \mu\, n^s_i \cdot f(\boldsymbol{\theta}_{\rm sig}) + n^b_i + \theta_i \sigma_i\right) \cdot \prod_{i=1}^{N} \mathcal{N}(\theta_i \mid 0, 1),\]where
\(n^s_i\) — signal yield in bin \(i\),
\(n^b_i\) — expected background yield in bin \(i\),
\(\sigma_i\) — absolute background uncertainty in bin \(i\) (e.g.
0.5for a yield reported as \(3.1 \pm 0.5\)),\(f(\boldsymbol{\theta}_{\rm sig})\) — optional signal-uncertainty modifier (1 by default).
The positivity constraint \(n^b_i + \theta_i \sigma_i \geq 0\) is enforced during optimisation via a
NonlinearConstraint.Because the bins are independent the log-likelihood factorises into a sum over bins, making this the fastest backend for quick estimates.
- Parameters:
signal_yields (
np.ndarray | Callable[[np.ndarray], np.ndarray]) – Per-bin signal yields \(\{n^s_i\}\), or a callable that accepts the extra signal parameterspars[1 : 1 + n_signal_parameters]and returns the per-bin yields as anp.ndarray.background_yields (
List[float]) – Per-bin expected background yields \(\{n^b_i\}\).data (
List[int]) – Per-bin observed counts \(\{n^{\rm obs}_i\}\).absolute_uncertainties (
List[float]) – Absolute (not relative) background uncertainties \(\{\sigma_i\}\). Must have the same length as the other array inputs.modifiers (
List[Dict[str, Any]], defaultNone) –Optional list of signal-uncertainty modifier configuration dictionaries. Each dictionary must contain:
"type"(str, required): morphing mode, either"normalization"— one shared nuisance parameter for all bins (e.g. PDF uncertainties, luminosity);"shape"— one independent nuisance parameter per bin (e.g. scale uncertainties, theory prediction statistics).
"uncertainties"(List[float] | List[Tuple[float, float]], required): absolute uncertainty values per bin. Use a flatlist[float]for symmetric uncertainties, or alist[(up, down)]for asymmetric ones."name"(str, optional): label used for parameter naming; defaults to"mod0","mod1", …
Not supported when
signal_yieldsis a callable.Example:
modifiers = [ {"type": "normalization", "name": "pdf", "uncertainties": [0.6, 1.0]}, {"type": "shape", "name": "scale", "uncertainties": [(0.3, 0.4), (0.5, 0.6)]}, ]
n_signal_parameters (
int, default0) – Number of additional free parameters accepted by a callablesignal_yields. Has no effect whensignal_yieldsis a plain array. SeeDefaultPDFBasefor the parameter-vector layout.signal_parameter_bounds (
List[Tuple[Optional[float], Optional[float]]] | None) – Optimiser bounds for each extra signal parameter. Each entry is a(lower, upper)pair; useNonefor an unbounded side. WhenNone, every extra signal parameter receives(None, None). Must have exactlyn_signal_parametersentries when provided.
Note
All input lists must have the same length \(N\) (number of bins/regions).
Example:
>>> import spey >>> stat_wrapper = spey.get_backend('default.uncorrelated_background') >>> data = [1, 3] >>> signal = [0.5, 2.0] >>> background = [2.0, 2.8] >>> background_unc = [1.1, 0.8] >>> stat_model = stat_wrapper( ... signal, background, data, background_unc, analysis="multi-bin", xsection=0.123 ... ) >>> print("CLs : %.3f" % tuple(stat_model.exclusion_confidence_level()))
- __init__(signal_yields: List[float] | Callable[[ndarray], ndarray], background_yields: List[float], data: List[int], absolute_uncertainties: List[float], modifiers: List[Dict[str, Any]] | None = None, n_signal_parameters: int = 0, signal_parameter_bounds: List[Tuple[float | None, float | None]] | None = None)[source]#
Methods
__init__(signal_yields, background_yields, ...)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[, include_auxiliary])Compute the expected data vector at the given parameter point.
get_hessian_logpdf_func([expected, data])Return a callable that evaluates the Hessian of \(\ln\mathcal{L}(\mu, \boldsymbol{\theta})\).
get_logpdf_func([expected, data])Return a callable that evaluates \(\ln\mathcal{L}(\mu, \boldsymbol{\theta})\).
get_objective_function([expected, data, do_grad])Return the objective function \(-\ln\mathcal{L}(\mu, \boldsymbol{\theta})\) used by the optimiser.
get_sampler(pars)Return a callable that draws pseudo-data from the statistical 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
constraintsConstraints to be used during optimisation process
signal_uncertainty_configurationauthorAuthor of the backend
constraint_modelConstraint model distribution \(\mathcal{C}(\boldsymbol{\theta})\).
is_aliveReturns True if at least one bin has non-zero signal yield.
main_modelMain model distribution — the Poisson term of the likelihood.
nameName of the backend
spey_requiresSpey version required for the backend
versionVersion of the backend