Analytic PDFs

In some circumstances, an analytic PDF is known and therefore we are not required to store samples from a distribution. In pesummary, we handle 1D analytic PDFs through the pesummary.utils.pdf.InterpolatedPDF class (inherited from the rv_continous class class in scipy) and pesummary.utils.pdf.DiscretePDF class (inherited from the rv_discrete class class in scipy). Two dimensional analytic PDFs are handled by the pesummary.utils.pdf.DiscretePDF2D class. We also store two dimensional analytic PDFs alongside their marginalized one dimensional analytic PDFs by the pesummary.utils.pdf.DiscretePDF2Dplus1D class.

class pesummary.utils.pdf.InterpolatedPDF(*args, **kwargs)[source]

Subclass of the scipy.stats._distn_infrastructure.rv_continous class. This class handles interpolated PDFs

interpolant

the interpolant to use when evaluate probabilities

Type:

func

pdf:

Evaluate the interpolant for a given input and return the PDF at that input

class pesummary.utils.pdf.DiscretePDF(*args, **kwargs)[source]

Subclass of the scipy.stats._distn_infrastructure.rv_sample class. This class handles discrete probabilities.

Parameters:
  • args (list, optional) – 2d list of length 2. First element integers, second element probabilities corresponding to integers.

  • values (list, optional) – 2d list of length 2. First element integers, second element probabilities corresponding to integers.

  • **kwargs (dict, optional) – all additional kwargs passed to the scipy.stats._distn_infrastructure.rv_sample class

x

array of integers with corresponding probabilities

Type:

np.ndarray

probs

array of probabilities corresponding to the array of integers

Type:

np.ndarray

interpolate:

interpolate the discrete probabilities and return a continuous InterpolatedPDF object

percentile:

calculate a percentile from the discrete PDF

write:

write the discrete PDF to file using the pesummary.io.write module

Examples

>>> from pesummary.utils.pdf import DiscretePDF
>>> numbers = [1, 2, 3, 4]
>>> distribution = [0.1, 0.2, 0.3, 0.4]
>>> probs = DiscretePDF(numbers, distribution)
>>> print(probs.x)
[1, 2, 3, 4]
>>> probs = DiscretePDF(values=[numbers, distribution])
>>> print(probs.x)
[1, 2, 3, 4]
class pesummary.utils.pdf.DiscretePDF2D(x, y, probability, **kwargs)[source]

Class to handle 2D discrete probabilities.

Parameters:

args (list, optional) – 2d list of length 3. First element integers for the x axis, second element inters for the y axis and third element, the 2d joint probability density.

x

array of integers for the x axis

Type:

np.ndarray

y

array of integers for the y axis

Type:

np.ndarray

probs

2D array of probabilities for the x y join probability density

Type:

np.ndarray

marginalize:

marginalize the 2D joint probability distribution to obtain the discrete probability density for x and y. Returns the probabilities as as a DiscretePDF2Dplus1D object

level_from_confidence:

return the level to use for plt.contour for a given confidence.

minimum_encompassing_contour_level:

return the minimum contour level that encompasses a specific point

Examples

>>> from pesummary.utils.pdf import DiscretePDF2D
>>> x = [1., 2., 3.]
>>> y = [0.1, 0.2, 0.3]
>>> probs = [
...     [1./9, 1./9, 1./9],
...     [1./9, 1./9, 1./9],
...     [1./9, 1./9, 1./9]
... ]
>>> pdf = DiscretePDF2D(x, y, probs)
>>> pdf.x
[1.0, 2.0, 3.0]
>>> pdf.y
[0.1, 0.2, 0.3]
>>> pdf.probs
array([[0.11111111, 0.11111111, 0.11111111],
       [0.11111111, 0.11111111, 0.11111111],
       [0.11111111, 0.11111111, 0.11111111]])
class pesummary.utils.pdf.DiscretePDF2Dplus1D(x, y, probabilities, **kwargs)[source]

Class to handle 2D discrete probabilities alongside 1D discrete probability distributions.

Parameters:

args (list, optional) – 3d list of length 3. First element integers for the x axis, second element inters for the y axis and third element, a list containing the probability distribution for x, y and the 2d join probability distribution xy.

x

array of integers for the x axis

Type:

np.ndarray

y

array of integers for the y axis

Type:

np.ndarray

probs

3D array of probabilities for the x axis, y axis and the xy joint probability density

Type:

np.ndarray

probs_x

the probability density function for the x axis stored as a DiscretePDF object

Type:

DiscretePDF

probs_y

the probability density function for the y axis stored as a DiscretePDF object

Type:

DiscretePDF

probs_xy

the joint probability density function for the x and y axes stored as DiscretePDF2D object

Type:

DiscretePDF2D

write:

write the discrete PDF to file using the pesummary.io.write module