2

I have a vector of angles and I am looking for a method to compute the distance of my vector with any other vector of angles? I am looking for something similar to Euclidean distance but I know that Euclidean is for non-circular values.

I should mention that I want to use this function as a cost function in an optimization process to find a vector of angles that is closest to my own vector of angles. How can I define something similar to the Euclidean norm for angular (circular) values?

Aep
  • 151
  • 4
  • what's the problem with euclidian distances? what are these angles of? – Aksakal Dec 09 '21 at 01:52
  • 1
    @Aksakal, these angles are phase values of a signal. Is it convenient to use euclidian distances for angles? I am worried about the unwrapping problem and similar problems that may happen for angular values? – Aep Dec 09 '21 at 03:04

2 Answers2

4

You are right that circular data requires special metrics. The distance between 1° and 359° should be small, e.g., not large as $|359-1|$ would suggest. And a circular metric must be "rotation-equivariant", i.e., it must not depend on the arbitrary choice where the angle 0° is located.

For distance measures, the cosine distance is often used and simple to compute: $$d(\varphi,\vartheta)=1-\cos(\varphi-\vartheta)$$ You can generalize it to vectors by component-wise addition.

It is also possible to define indices somehow representing mean values and variances for circular data. See

Jammalamadaka, SenGupta: "Topics in Circular Statistics." World Scientific, 2001

cdalitz
  • 2,844
  • 6
  • 13
2

The simple approach is to measure the distance linearly as if they were Euclidian: $d^2(\theta,\phi)=\sum_i(\phi_i-\theta_i)^2$. You must handle cases like $\theta_i=359$ and $\phi_i=1$, where the distance must be 2 not 358, of course. Handling angles linearly can make sense, the circumference is linear on angles.

The other way is with cosine:$$d^2(\theta,\phi)=\sum_i(1-\cos(\phi_i-\theta_i))^2$$

You can make this even fancier $$d^2(\theta,\phi)=\sum_i\left(\frac{1-\cos(\phi_i-\theta_i)}{1+\cos(\phi_i-\theta_i)}\right)^2$$ This distance goes to infinity when the phase difference is near 180, which maybe what you want depending on your application.

Note that in the above approaches the circularity is only addressed at the vector component level, then the distance to entire vector is calculated as in Euclidian space. This may not be what you want.

Consider this example: you have a vector in space and the angles are components representing its direction, maybe gyroscope angles. Now the real distance from one such vector to another is a projection of one vector onto another. Then the angle (distance) is $$d(\phi,\theta)=1+\sum_i\cos\phi_i\times\cos\theta_i $$ This is an example where the distance metric is dictated by the application. Also it is the case where the set of all possible vectors $\phi,\theta$ is not a full Euclidian space $\mathbf R^3$ but a subset where the squared sum of cosines should add up to 1 for each vector:$$\sum_i\cos^2\phi_i=1$$ In these cases Euclidian distance is usually not the best because the straight line from one vector to another will likely leave the subspace of possible vectors and go through areas of impossible vectors.

You have to consider what are your angle vectors exactly, not just the circularity, but whether the set of possible vectors forms manifold or subspace in Euclidian space. This will inform you on what are the suitable distance metrics.

Aksakal
  • 55,939
  • 5
  • 90
  • 176