TITLE: Finding the orientation of a noisy ellipse
QUESTION [7 upvotes]: This question comes from a neuroscience study which generates $12$ vectors. The vectors are evenly spaced, $30 n$ degrees for $n=0,\dots, 11$, each with their tail centered on the origin.
I am looking for biases in each set of vectors, in which one orientation is favored. By this I mean that there may be $2$ peaks opposed from one another (by $180^{\circ}$). So I am wondering what you think is the simplest way to estimate the "orientation" with the greatest magnitude, given that the measurements are discrete, and the true peak may be between datapoints.
The data can be considered random, but the ideal case would look something like an ellipse centered on the origin, with $2$ equal and opposed maxima and minima. I suppose another way to frame the question would be how to find the direction of the major axis of an ellipse when plotted discretely over $12$ uniformly distributed theta values between $0^{\circ}$ and $360^{\circ}$. But one has to consider that the plot may also include significant random noise, so finding one peak is not enough to definitively tell the orientation of the ellipse.
I first learned to do this for a single peak, which would resemble a cardioid. This was simple: the direction of bias could be estimated by taking the vector sum of the $12$ vectors. Now that I am working with $2$ peaks, I do not feel as certain about my technique, but I have made an attempt:

Take the sum of the magnitudes of opposing vectors 
Assign them to 6 evenly spaced vectors with $\theta = {60n}^{\circ}$ for $n=0,\dots, 11$
Vector sum
Divide $\theta$ of $V_{sum}$ by $2$

This solution seems too simple to be right... and I don't have the skill to prove or disprove it. Would this reliably determine the orientation of a low resolution ellipse?

REPLY [3 votes]: Take the Discrete Fourier Transform of the vector lengths $\bf v$.
The 2nd order coefficient, actually its phase, gives you the angle you are requesting; remember to divide by two.
Octave (Matlab) code is straightforward:
F=fft(V);
a=angle(F(3))/2;   # 3rd element = 2nd order coefficient

but with 12 points you can easily write down the full expansion for the desired coefficients as a linear combination of all vectors where coefficients are sines and cosines of easy angles (and you can obtain the real/imag parts separately with operations that just involve real numbers).
Then you only need one transcendent operation i.e. the arctan() to get the angle.
The strength of the method is, that the result is invariant for a shift of the 12 vector pattern, as required.

But there's more. Beside the requested angle, it gives you a measurement of the mentioned "noise".
In fact, the ratio 
$$ 
\frac{2 \cdot |F(3)|^2}{12 \cdot \sum{\bf v}_i^2}  (*)
$$ 
measures how much the two-lobe effect (this is what is meant with "ellipse", afaik) is relevant compared to the rest of the noise. You can use this ratio as a percentage, as it is energetically meaningful (by Parseval's theorem)
(*) Note. The $12$ factor at denominator depend on actual formula used for discrete Fourier transform. The above is valid for Octave (Matlab).
More in detail, using also the other coefficients, you can tell how big is the "two-lobe" effect compared to various k-lobed "modes" (you would probably call noise only those with k>2).
In fact, once found the F coefficients, their modula measure the amplitudes of the n-lobe modes. I.e. more exactly:

0th order i.e. $|F(1)|^2$, gives the weight of the constant mode (0-lobes)
kth order, $|F(1+k)|^2+|F(12-k)|^2 == 2 \cdot|F(1+k)|^2$, is the weight of the k-lobe mode (k in 1:5)
6th order, $|F(7)|^2$, gives the weight of the the 6-lobed mode, i.e. the maximum angular frequency mode.

In conclusion:

$\frac{2 \cdot |F(3)|^2}{12 \cdot \sum{\bf v}_i^2}$ is the percentage of the data energy which is reated to the two lobes
$\frac{|F(1)|^2 + 2 \cdot |F(2)|^2}{12 \cdot \sum{\bf v}_i^2}$ measures the low frequency "noise" (or bias, name it as you want)
$\frac{2 \cdot |F(4)|^2+2 \cdot |F(5)|^2+2 \cdot |F(6)|^2 + |F(7)|^2}{12 \cdot \sum{\bf v}_i^2}$ measures the energy in the higher order modes (call it the hi frequency noise)

That's why I find the Fourier representation of variability particularly meaningful when explaining variability of data representable in polar plots.