spey.backends.default_pdf.CorrelatedBackground#
- class spey.backends.default_pdf.CorrelatedBackground(signal_yields: ndarray, background_yields: ndarray, data: ndarray, covariance_matrix: ndarray, signal_uncertainty_configuration: Dict[str, Any] | None = None)[source]#
Correlated multi-region statistical model. The correlation between each nuisance parameter has been captured via Multivariate Normal distribution and the log-probability distribution is combination of Multivariate Normal along with Poisson distribution. The Multivariate Normal distribution is constructed by the help of a covariance matrix provided by the user which captures the uncertainties and background correlations between each histogram bin. The probability distribution of a simplified likelihood can be formed as follows;
\[\mathcal{L}_{SL}(\mu,\theta) = \underbrace{\left[\prod_i^N {\rm Poiss}\left(n^i_{obs} | \lambda_i(\mu, \theta)\right) \right]}_{\rm main\ model} \cdot \underbrace{\mathcal{N}(\theta | 0, \rho)}_{\rm constraint\ model}\]Here the first term is the so-called main model based on Poisson distribution centred around \(\lambda_i(\mu, \theta) = \mu n^i_{sig} + \theta + n^i_{bkg}\) and the second term is the multivariate normal distribution centred around zero with the correlation matrix \(\rho\).
- Parameters:
signal_yields (
np.ndarray
) – signal yieldsbackground_yields (
np.ndarray
) – background yieldsdata (
np.ndarray
) – observationscovariance_matrix (
np.ndarray
) – covariance matrix (square matrix)signal_uncertainty_configuration (
Dict[Text, Any]]
, defaultNone
) –Configuration input for signal uncertainties
absolute_uncertainties (
List[float]
): Absolute uncertainties for the signal- absolute_uncertainty_envelops (
List[Tuple[float, float]]
): upper and lower uncertainty envelops
- absolute_uncertainty_envelops (
correlation_matrix (
List[List[float]]
): Correlation matrixthird_moments (
List[float]
): diagonal elemetns of the third moment
Note
Each input should have the same dimensionality, i.e. if
data
has three regions,signal_yields
andbackground_yields
inputs should have three regions as well. Additionallycovariance_matrix
is expected to be square matrix, thus for a three region statistical model it is expected to be 3x3 matrix.Example:
>>> import spey >>> stat_wrapper = spey.get_backend('default_pdf.correlated_background') >>> signal_yields = [12.0, 11.0] >>> background_yields = [50.0, 52.0] >>> data = [51, 48] >>> covariance_matrix = [[3.,0.5], [0.6,7.]] >>> statistical_model = stat_wrapper(signal_yields,background_yields,data,covariance_matrix) >>> print(statistical_model.exclusion_confidence_level())
- __init__(signal_yields: ndarray, background_yields: ndarray, data: ndarray, covariance_matrix: ndarray, signal_uncertainty_configuration: Dict[str, Any] | None = None)[source]#
Methods
__init__
(signal_yields, background_yields, ...)asimov_negative_loglikelihood
([poi_test, ...])Compute negative log-likelihood at fixed \(\mu\) for Asimov data.
combine
(other, **kwargs)A routine to combine to statistical models.
config
([allow_negative_signal, poi_upper_bound])Model configuration.
expected_data
(pars[, include_auxiliary])Compute the expected value of the statistical model
get_hessian_logpdf_func
([expected, data])Currently Hessian of \(\log\mathcal{L}(\mu, \theta)\) is only used to compute variance on \(\mu\).
get_logpdf_func
([expected, data])Generate function to compute \(\log\mathcal{L}(\mu, \theta)\) where \(\mu\) is the parameter of interest and \(\theta\) are nuisance parameters.
get_objective_function
([expected, data, do_grad])Objective function i.e. twice negative log-likelihood, \(-2\log\mathcal{L}(\mu, \theta)\).
get_sampler
(pars)Retreives the function to sample from.
minimize_asimov_negative_loglikelihood
([...])A backend specific method to minimize negative log-likelihood for Asimov data.
minimize_negative_loglikelihood
([expected, ...])A backend specific method to minimize negative log-likelihood.
negative_loglikelihood
([poi_test, expected])Backend specific method to compute negative log-likelihood for a parameter of interest \(\mu\).
Attributes
constraints
Constraints to be used during optimisation process
signal_uncertainty_configuration
author
Author of the backend
constraint_model
retreive constraint model distribution
is_alive
Returns True if at least one bin has non-zero signal yield.
main_model
retreive the main model distribution
name
Name of the backend
spey_requires
Spey version required for the backend
version
Version of the backend