Density#
- class cuqi.density.Density(name=None)#
Abstract base class for densities.
Exposes a unified interface for evaluating the log density depending on the parameters of the density. Common subclasses are Distribution and Likelihood.
- Parameters:
name (str) – Name of the random variable associated with the density.
Notes
Subclasses must implement the following:
_logd(self, *args, **kwargs). Returns the log density given a set of parameters.
_condition(self, *args, **kwargs). This method conditions (fixes) the density on a given set of parameters.
dim. The dimension of the density.
get_parameter_names(self). Returns a list of the names of the parameters of the density.
- __init__(name=None)#
Methods
__init__
([name])Disable finite difference approximation for logd gradient.
enable_FD
([epsilon])Enable finite difference approximation for logd gradient.
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)Evaluates the un-normalized log density function given a set of parameters.
Attributes
Returns True if finite difference approximation of the logd gradient is enabled.
Spacing for the finite difference approximation of the logd gradient.
Name of the random variable associated with the density.