Prior.constrain#

Prior.constrain(lower, upper, mass=0.95, kwargs=None)[source]#

Create a new prior with a given mass constrained within the given bounds.

Wrapper around preliz.maxent.

Parameters:
lowerfloat

The lower bound.

upperfloat

The upper bound.

mass: float = 0.95

The mass of the distribution to keep within the bounds.

kwargsdict

Additional arguments to pass to pz.maxent.

Returns:
Prior

The maximum entropy prior with a mass constrained to the given bounds.

Examples

Create a Beta distribution that is constrained to have 95% of the mass between 0.5 and 0.8.

dist = Prior(
    "Beta",
).constrain(lower=0.5, upper=0.8)

Create a Beta distribution with mean 0.6, that is constrained to have 95% of the mass between 0.5 and 0.8.

dist = Prior(
    "Beta",
    mu=0.6,
).constrain(lower=0.5, upper=0.8)