Can you put constraints on latent variables in Numpyro

Hi there,

I am familiar with the rationale that latent variables cannot be constrained in Pyro, partly due to difficulties this causes with SVI.

I was wondering if this was the case for Numpyro, also. Effectively I have two latent variables, and I know with absolute certainty that one is always greater than the other.

Thanks for the help.

It depends on the underlying distributions. If they have real supports, you can use improper distribution with OrderedVector support (then add unnormailzed factors of log probs of the values), like

xy = sample("xy", dist.ImproperUniform(...))
numpyro.factor("x_log_prob", dx.log_prob(xy[0]))
1 Like