Hello devs,
Suppose k is a real values stochastic site of the model. If I were to discourage negative posterior values for k, I would put the following penalty as a soft constraint:
k = numpyro.sample("k", dist.Normal(loc=4, scale=5))
penalty_for_negative_k = (
jnp.fabs(k) - k
)
numpyro.factor(
"penalty_for_negative_k", -penalty_for_negative_k
)
However, if k were positive, and I wanted to discourage small values for k. I think the following penalty works, but I was wondering if you knew of a better penalty / or one that’s more commonly used for this purpose?
k = numpyro.sample("k", dist.HalfNormal(scale=5))
penalty_for_small_k = -jnp.log(k)
numpyro.factor(
"penalty_for_small_k", -penalty_for_small_k
)
Thanks for your help!