InverseGamma#

class cuqi.distribution.InverseGamma(shape=None, location=None, scale=None, is_symmetric=False, **kwargs)#

Multivariate inverse gamma distribution of independent random variables x_i. Each is distributed according to the PDF function

\[f(x) = (x-\beta)^{(-\alpha-1)} * \exp(-\gamma/(x-\beta)) / (\gamma^{(-\alpha)}*\Gamma(\alpha))\]

where shape \(\alpha\), location \(\beta\) and scale \(\gamma\) are the shape, location and scale of x_i, respectively. And \(\Gamma\) is the Gamma function.

Parameters:
  • shape (float or array_like) – The shape parameter

  • location (float or array_like) – The location of the inverse gamma distribution. The support of the pdf function is the Cartesian product of the open intervals (location_1, infinity), (location_2, infinity), …, (location_dim, infinity).

  • scale (float or array_like) – The scale of the inverse gamma distribution (non-negative)

Example

# Generate an InverseGamma distribution
import numpy as np
import cuqi
import matplotlib.pyplot as plt
shape = [1,2]
location = 0
scale = 1
rng = np.random.RandomState(1)
x = cuqi.distribution.InverseGamma(shape, location, scale)
samples = x.sample(1000, rng=rng)
samples.hist_chain(0, bins=70)
plt.figure()
samples.hist_chain(1, bins=70)
__init__(shape=None, location=None, scale=None, is_symmetric=False, **kwargs)#

Initialize the core properties of the distribution.

Parameters:
  • name (str, default None) – Name of distribution.

  • geometry (Geometry, default _DefaultGeometry (or None)) – Geometry of distribution.

  • is_symmetric (bool, default None) – Indicator if distribution is symmetric.

Methods

__init__([shape, location, scale, is_symmetric])

Initialize the core properties of the distribution.

cdf(x)

disable_FD()

Disable finite difference approximation for logd gradient.

enable_FD([epsilon])

Enable finite difference approximation for logd gradient.

get_conditioning_variables()

Return the conditioning variables of this distribution (if any).

get_mutable_variables()

Return any public variable that is mutable (attribute or property) except those in the ignore_vars list

get_parameter_names()

Returns the names of the parameters that the density can be evaluated at or conditioned on.

gradient(*args, **kwargs)

Returns the gradient of the log density at x.

logd(*args, **kwargs)

Evaluate the un-normalized log density function of the distribution.

logpdf(x)

Evaluate the log probability density function of the distribution.

pdf(x)

Evaluate the log probability density function of the distribution.

sample([N])

Sample from the distribution.

to_likelihood(data)

Convert conditional distribution to a likelihood function given observed data

Attributes

FD_enabled

Returns True if finite difference approximation of the logd gradient is enabled.

FD_epsilon

Spacing for the finite difference approximation of the logd gradient.

dim

Return the dimension of the distribution based on the geometry.

geometry

Return the geometry of the distribution.

is_cond

Returns True if instance (self) is a conditional distribution.

name

Name of the random variable associated with the density.