Simultaneous#

class pyhf.probability.Simultaneous(pdfobjs, tensorview, batch_size=None)[source]#

Bases: object

A probability density corresponding to the joint distribution of multiple non-identical component distributions

Example

>>> import pyhf
>>> import numpy.random as random
>>> from pyhf.tensor.common import _TensorViewer
>>> random.seed(0)
>>> poissons = pyhf.probability.Poisson(pyhf.tensorlib.astensor([1.,100.]))
>>> normals = pyhf.probability.Normal(pyhf.tensorlib.astensor([1.,100.]), pyhf.tensorlib.astensor([1.,2.]))
>>> tv = _TensorViewer([[0,2],[1,3]])
>>> sim = pyhf.probability.Simultaneous([poissons,normals], tv)
>>> sim.sample((4,))
array([[  2.        ,   1.3130677 , 101.        ,  98.29180852],
       [  1.        ,  -1.55298982,  97.        , 101.30723719],
       [  1.        ,   1.8644362 , 118.        ,  98.51566996],
       [  0.        ,   3.26975462,  99.        ,  97.09126865]])
__init__(pdfobjs, tensorview, batch_size=None)[source]#

Construct a simultaneous pdf.

Parameters:
  • pdfobjs (Distribution) – The constituent pdf objects

  • tensorview (_TensorViewer) – The _TensorViewer defining the data composition

  • batch_size (int) – The size of the batch

Methods

static _joint_logpdf(terms, batch_size=None)[source]#
expected_data()[source]#

The expectation value of the probability density function.

Returns:

The expectation value of the distribution \(\mathrm{E}\left[f(\theta)\right]\)

Return type:

Tensor

log_prob(value)[source]#

The log of the probability density function at the given value.

Parameters:

value (tensor) – The observed value

Returns:

The value of \(\log(f\left(x\middle|\theta\right))\) for \(x=\)value

Return type:

Tensor

sample(sample_shape=())[source]#

The collection of values sampled from the probability density function.

Parameters:

sample_shape (tuple) – The shape of the sample to be returned

Returns:

The values \(x \sim f(\theta)\) where \(x\) has shape sample_shape

Return type:

Tensor