I’m trying to uniformly sample a vector of random variables a such that \sum_i a_i = 1 and a_i < c_i
I can easily fulfill the equality constraint by sampling x \sim \mathrm{Exponential}(\lambda=1) and then normalizing a = x / \sum(x).
However, I’m having problems implementing the inequality constraint with pm.Potential
with pm.Model() as model:
x = [pm.Exponential(f"x{i}", lam=1) for i in range(3)]
a = pm.Deterministic("a", x / tt.sum(x))
c0 = pm.Potential('c0', tt.switch(tt.le(a[0], 0.3), 0, -np.inf)) # require that a0 < 0.3
trace = pm.sample()
gives
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (2 chains in 2 jobs)
NUTS: [x2, x1, x0]
Sampling 2 chains: 0%| | 0/2000 [00:00<?, ?draws/s]/usr/lib/python3.7/site-packages/numpy/core/fromnumeric.py:3118: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
/usr/lib/python3.7/site-packages/numpy/core/fromnumeric.py:3118: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
Bad initial energy, check any log probabilities that are inf or -inf, nan or very small:
Series([], )
Any ideas what could be wrong?