Circular transformation has a zero-valued Jacobian

Hi,

So I have noticed that the circular transform provided by PyMC3 has a zero-valued Jacobian. Wouldn’t this pose an issue for differentiation-based inference like NUTS and ADVI?

I recall having had some issues with NaN’s when using a mixture of VonMises distributions (An extended model of the one presented in NaN occured in optimization in a VonMises mixture model), which were solved when I used a mixture of Normals instead.
Could this be the potential cause?

Thank you in advance!

Hmmm @aloctavodia any idea? I think we need jacobian https://math.oregonstate.edu/home/programs/undergrad/CalculusQuestStudyGuides/vcalc/jacpol/jacpol.html?

I think we are OK without the jacobian. Intuitively because the transformation is not stretching or compressing anything is just ensuring that any value sampled in R is wrapped back to the unit circle. Is like having periodic boundary conditions. But my intuition could be failing here.

The Jacobian is used to calculate the logp value of a transformed distribution, here: https://github.com/pymc-devs/pymc3/blob/bf53d686c829d534a32ef7655e6bed2638d255f4/pymc3/distributions/transforms.py#L53

My guess is that this would give the wrong result when it is constant zero, but I am not completely sure.

Oh, I see that it is only added to the original value, so maybe it does not affect the result when it is 0.

Thanks for the replies!

Not to reopen an old thread, but I finally figured out why I misunderstood (now that I am taking a look at transformations again). The calculated value is the logarithm of the absolute value of the Jacobian determinant :smile:. I will make a pull request with some documentation.