Why cant Uniform or Bounded distributions take upper & lower values as arrays?

With, for example, a pm.Normal distribution, we can run the following and produce a vector with shape 4:
pm.Normal("a", mu=np.array([4,6,2,7]),sd=np.array([1,1,2,3]),shape=4)

I don’t understand why the same functionality does not apply to a bounded variable, e.g.:
pm.Bound(pm.Normal,lower=np.array([0,1,0,2]),upper=np.array([8,9,7,9]))("a", mu=np.array([4,6,2,7]),sd=np.array([1,1,2,3]),shape=4)

Or a uniform one:

The alternative is that I loop over 50 values and create 50 individual parameters which seems to clog up the model at a later point - so encapsulating them all in a single variable would obviously be preferable Can anyone help me here?

I tried using the vector bounds and it worked fine:

import numpy as np
import pymc3 as pm

lb = np.array([0,1,0,2])
ub = np.array([8,9,7,9])
with pm.Model() as model:
    BoundNormal = pm.Bound(pm.Normal,lower=lb, upper=ub)
    a = BoundNormal("a", mu=np.array([4,6,2,7]),sd=np.array([1,1,2,3]),shape=4)
    trace = pm.sample()
assert np.all(np.logical_and(trace['a'] >lb, trace['a']<ub))

Was this code failing as part of a larger model?

You know what, I was sure it was pymc3 breaking and not a silly fault I had made.
But it turns out lower has to be, you know, lower than upper.
hangs head in shame.

1 Like