Independent#

class pyhf.probability.Independent(batched_pdf, batch_size=None)[source]#

Bases: pyhf.probability._SimpleDistributionMixin

A probability density corresponding to the joint distribution of a batch of identically distributed random variables.

Example

>>> import pyhf
>>> import numpy.random as random
>>> random.seed(0)
>>> rates = pyhf.tensorlib.astensor([10.0, 10.0])
>>> poissons = pyhf.probability.Poisson(rates)
>>> independent = pyhf.probability.Independent(poissons)
>>> independent.sample()
array([10, 11])
__init__(batched_pdf, batch_size=None)[source]#
Parameters:
  • batched_pdf (pyhf.probability distribution) – The batch of pdfs of the same type (e.g. Poisson)

  • batch_size (int) – The size of the batch

Methods

log_prob(value)[source]#

The log of the probability density function at the given value. As the distribution is a joint distribution of the same type, this is the sum of the log probabilities of each of the distributions the compose the joint.

Example

>>> import pyhf
>>> import numpy.random as random
>>> random.seed(0)
>>> rates = pyhf.tensorlib.astensor([10.0, 10.0])
>>> poissons = pyhf.probability.Poisson(rates)
>>> independent = pyhf.probability.Independent(poissons)
>>> values = pyhf.tensorlib.astensor([8.0, 9.0])
>>> independent.log_prob(values)
-4.26248380...
>>> broadcast_value = pyhf.tensorlib.astensor([11.0])
>>> independent.log_prob(broadcast_value)
-4.34774364...
Parameters:

value (tensor or float) – The value at which to evaluate the distribution

Returns:

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

Return type:

Tensor