spey.backends.default_pdf.simple_pdf.MultivariateNormal#
- class spey.backends.default_pdf.simple_pdf.MultivariateNormal(signal_yields: List[float], background_yields: List[float], data: List[int], covariance_matrix: List[List[float]] | callable)[source]#
Multivariate Gaussian distribution.
\[\mathcal{L}(\mu) = \frac{1}{\sqrt{(2\pi)^k {\rm det}[\Sigma] }} \exp\left[-\frac{1}{2} (\mu n_s + n_b - n)\Sigma^{-1} (\mu n_s + n_b - n)^T \right]\]where \(n_{s,b}\) are signal and background yields and \(n\) are the observations.
Added in version 0.1.9.
covariance_matrixcan also take callable function as an input where function takes nuisance parameters as inputs and return a new covariance matrix as output.Example:
>>> import spey >>> import numpy as np >>> signal_yields = np.array([12.0, 15.0]) >>> background_yields = np.array([50.0, 48.0]) >>> data = np.array([36., 33.]) >>> covariance_matrix = np.array([[144.0, 13.0], [25.0, 256.0]]) >>> covariance_signal = np.array([[5.0, 1.0], [2.0, 3.0]]) >>> def cov_matrix(pars: np.ndarray) -> np.ndarray: >>> return covariance_matrix + covariance_signal * pars[0]**2 >>> pdf_wrapper = spey.get_backend('default.multivariate_normal') >>> model = pdf_wrapper( ... signal_yields=signal_yields, ... background_yields=background_yields, ... data=data, ... covariance_matrix=cov_matrix, ... )
Changed in version 0.2.6: The ability to input a callable covariance matrix has been added.
- Parameters:
signal_yields (
List[float]) – signal yieldsbackground_yields (
List[float]) – background yieldsdata (
List[int]) – datacovariance_matrix (
List[List[float]] | callable) –covariance matrix (square matrix)
If you have correlation matrix and absolute uncertainties please use
correlation_to_covariance()
- __init__(signal_yields: List[float], background_yields: List[float], data: List[int], covariance_matrix: List[List[float]] | callable)[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, **kwargs)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. negative log-likelihood, \(-\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
covariance_matrixauthorAuthor of the backend
background_yieldsdatais_aliveReturns True if at least one bin has non-zero signal yield.
main_modelretreive the main model distribution
nameName of the backend
signal_yieldsspey_requiresSpey version required for the backend
versionVersion of the backend
constraintsConstraints to be used during optimisation process