Prior.constrain#

Prior.constrain(lower, upper, **kwargs)[source]#

Create a new prior that is constrained to the given bounds.

Wrapper around pm.find_constrained_prior where the initial guess is the current parameters. Will error out if no parameters are given.

Parameters:
lowerfloat

The lower bound.

upperfloat

The upper bound.

kwargsdict

Additional arguments to pass to pm.find_constrained_prior.

Returns:
Prior

The new prior that is constrained to domain.

Examples

Create a Beta distribution that is constrained between 0.5 and 0.8 using initial parameter values of alpha=2 and beta=1 for the optimization.

dist = Prior(
    "Beta",
    alpha=2,
    beta=1,
).constrain(lower=0.5, upper=0.8)