pymc.distributions.transforms.Interval#

class pymc.distributions.transforms.Interval(lower=None, upper=None, *, bounds_fn=None)[source]#

Wrapper around aeppl.transforms.IntervalTransform for use in the transform argument of a random variable.

Parameters
lowerint or float, optional

Lower bound of the interval transform. Must be a constant finite value. By default (lower=None), the interval is not bounded below.

upperint or float, optional

Upper bound of the interval transform. Must be a constant finite value. By default (upper=None), the interval is not bounded above.

bounds_fncallable(), optional

Alternative to lower and upper. Must return a tuple of lower and upper bounds as a symbolic function of the respective distribution inputs. If one of lower or upper is None, the interval is unbounded on that edge.

Warning

Expressions returned by bounds_fn should depend only on the distribution inputs or other constants. Expressions that depend on nonlocal variables, such as other distributions defined in the model context will likely break sampling.

Examples

# Create an interval transform between -1 and +1
with pm.Model():
    interval = pm.distributions.transforms.Interval(lower=-1, upper=1)
    x = pm.Normal("x", transform=interval)
# Create an interval transform between -1 and +1 using a callable
def get_bounds(rng, size, dtype, loc, scale):
    return 0, None

with pm.Model():
    interval = pm.distributions.transforms.Interval(bouns_fn=get_bounds)
    x = pm.Normal("x", transform=interval)
# Create a lower bounded interval transform based on a distribution parameter
def get_bounds(rng, size, dtype, loc, scale):
    return loc, None

interval = pm.distributions.transforms.Interval(bounds_fn=get_bounds)

with pm.Model():
    loc = pm.Normal("loc")
    x = pm.Normal("x", mu=loc, sigma=2, transform=interval)

Methods

Interval.__init__([lower, upper, bounds_fn])

Parameters

Interval.backward(value, *inputs)

Invert the transformation.

Interval.forward(value, *inputs)

Apply the transformation.

Interval.log_jac_det(value, *inputs)

Construct the log of the absolute value of the Jacobian determinant.

Attributes

name