Parametrizing geometric direction

I’m fitting a model, which contains several 2d vectors having the same direction. Currently, I use the very intuitive way to parametrize them:

angle = pm.VonMises(...)
direction = tt.stack(tt.cos(angle), tt.sin(angle))
coeffs = pm.Normal(..., shape=nvec)
vectors = direction * coeffs

this kinda works and leads to a reasonable posterior, but obviously suffers from nonidentifyability: replacing angle with angle + 180º and coeffs with -coeffs doesn’t affect vectors. I couldn’t think of any way to fix it: taking angle as being defined on -90º...90º leads to a discontinuity (taking angle = arctan(x) also does); constraining coeffs > 0 in my case doesn’t work because they may have different signs;

What can be done in this case?

1 Like

Have you tried the solution in How to model sinusoids in white gaussian noise?

But how does it help with the angle - angle + 180 ambiguity? If I parametrize the direction vector as a pair of its cartesian coordinates (a, b) then it adds yet another ambiguity - (a, b) with coeffs and (a / c, b / c) with c * coeffs.

Actually, i think you should model the amplitude as always positive. So that direction becomes a unit vector on the unit circle, and you just scale it with a positive coefficient.

Well, and what if I need some vectors to be in different (opposite) directions to each other? Like vectors[0] = 1 * direction and vectors[1] = -1 * direction.

Hmm, in that case, maybe it would make sense to have model direction between (-\pi/2, \pi/2), Something like:

angle = pm.VonMises(...)
direction = tt.stack(tt.cos(angle/2), tt.sin(angle/2))
coeffs = pm.Normal(..., shape=nvec)
vectors = direction * coeffs

So that angle is still continous between -90º and 90º

Yes, I thought about it and mentioned in the first post. A problem here is that when the angle changes from \pi/2 to -\pi/2 there is a discontinuity: direction vector changes sign, so all coeffs also have to.

Oh I see what you meant now in the original post now. So basically you are modelling a set of vectors that have the same mirror angle.

Do you have a notebook with data on this?

Currently, I have a more complex model including these vectors as a part (as they are not directly observed), but will try to make a small example. I just thought that some advice may be possible without too much detail on the exact model :)

More informative prior for theta (angle) should help, but then more details about your model is needed to know what is a good prior.