Nonlinear transformation from R² to R

You can’t transform probability density functions between two real spaces of different dimensions – the Jacobian update rule is valid only when the input space and output space have the same dimension and the Jacobian matrix is square and the Jacobian determinant well-defined.
What you really have to do instead is buffer your output space with auxiliary variables to define a one-to-one transformation, compute the corresponding Jacobian, and then marginalize if you can.

For your transformation you could try to bring in the angle that complements the radius, i.e. transform from (real_x, real_y) to m, theta, but that works only if the possible angles are constrained so that you can avoid the singularity that arises at one of the values of m or one of the values of theta. You’ve run into a deeper problem in that you can’t transform densities between spaces of different topologies, and if you try you either get an infinite series (because the map from real_x and real_y to m and theta is multivalued) or singularities where the Jacobian seems to explode.

Here you can get around those troubles by specifying prior densities in each quadrant of the real_x, real_y plane and then piecing the resulting Jacobians together with if-statements if they differ by quadrant. You can also try to avoid transforming between densities directly and try to construct cumulative distribution functions on the output space and differentiate those; see for example the derivation of the Rayleigh density functions in https://en.wikipedia.org/wiki/Rayleigh_distribution#Relation_to_random_vector_length.

Anyways, all of this technical trouble is a good indication that this is a weird prior model that will lead to weird posteriors and you may want to reconsider (if your data are weak and the prior on m dominates then you end up with a highly degenerate, annular posterior density).

5 Likes