Skip to content

← distributions package

DistributionHighestDensityInterval

Calculate the highest probability density interval (HPDI) of a provided (wired-in) probability distribution.

This returns a pair of values -- a lower and upper bound. For univariate distributions, each of these is a scalar, but the value will be an array if the distribution's event space is multivariate, and/or if the distribution itself is batched, as in, is parameterized by a batch of parameters (e.g., multiple sets of locations or scales). In these cases, the shape of the result is (batch_shape, event_shape). For the distributions defined in the distributions package, this yields generally the analytic, i.e. exact, result, but the measure is defined in terms of the icdf and is only available for combinations of distributions and backends that have an icdf defined (your best bets are scipy (all distributions), numpyro (most), and torch (a few)). For sampling-based distributions (e.g., those obtained from one of the Inference nodes), this will generally be an approximation. For distributions defined over multiple named random variables (e.g., posterior distributions), the result will be a Packet whose chunks are named after the random variables. More Info... Version 1.0.0

Ports/Properties

dist

Distribution to use.

verbose name
Dist
default value
None
port type
DataPort
value type
Distribution (can be None)
data direction
IN

lower

Lower bound (less than median).

verbose name
Lower
default value
None
port type
DataPort
value type
object (can be None)
data direction
OUT

upper

Upper bound (greater than median).

verbose name
Upper
default value
None
port type
DataPort
value type
object (can be None)
data direction
OUT

probability

Probability of values lying in interval. The resulting range will be such that values fall into the range with this probability. For (approximately) symmetric distributions, this will be a central interval, i.e. the probability of values falling below the lower bound will be 1-probability/2, and the probability of values falling above the upper bound will be 1-probability/2.

verbose name
Probability
default value
0.9
port type
FloatPort
value type
float (can be None)

set_breakpoint

Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.

verbose name
Set Breakpoint (Debug Only)
default value
False
port type
BoolPort
value type
bool (can be None)

metadata

User-definable meta-data associated with the node. Usually reserved for technical purposes.

verbose name
Metadata
default value
{}
port type
DictPort
value type
dict (can be None)

axis_pairing

How to pair axes of the distribution and the operand. In 'positional' mode, axes are paired by their position according to a right alignment, that is, the last axis of the first operand is paired with the last axis of the second operand, and so on, while any missing axes behave as if they were unnamed axes of length 1 (this is the same way plain n-dimensional arrays pair in Python/numpy). In 'matched' mode, axes are paired by their type and optionally label, where the axis order of the first operand is preserved in the output, optionally with additional axes that only occur in the subsequent operands prepended on the left. The other operands then have their axes reordered to match. In matched mode, the axes will also follow the order dictated by any ambient plate (With Stacked Variables) context if those contexts were set to pertain to an axis. All axis classes are treated as distinct, except for the plain axis, which is treated as a wildcard axis that can pair with any other axis. The 'default' value resolves to a value that may be overridden in special contexts (mainly the ambient Inference node) and otherwise resolves to the setting of the configuration variable default_axis_pairing, which is set to 'positional' in 2024.x. See also the 'label_handling' property for how labels are treated in this mode. Note that axis pairing can be subtle, and it is recommended to not blindly trust that the default behavior is always what the user intended.

verbose name
Axis Pairing
default value
default
port type
EnumPort
value type
str (can be None)

label_pairing

How to treat axis labels when pairing axes in 'matched' mode. In 'always' mode, labels are always considered significant, and axes with different labels are always considered distinct, which means that, if the two operands each have an axis of same type but with different labels, each operand will have a singleton axis inserted to pair with the respective axis in the other operand. In 'ignore' mode, labels are entirely ignored when pairing axes; this means that, if multiple axes of the same type occur in one or more operands, the last space axis in the first operand is paired with the last space axis in the second operand, etc. as in positional mode. In 'auto' mode, labels are only considered significant if they are necessary for distinguishing two or more axes of the same type in any of the operands, or if they occur on a plain axis.

verbose name
Label Pairing
default value
auto
port type
EnumPort
value type
str (can be None)