# PCA trick to ensure consistent eigenvector signs

• Short Description. I am doing PCA on an image at a time, and for each eig operation I store the 1st eigenvector. After each is found, I then average the 1st of eigenvectors that I stored for each of the images. The eigenvectors have real and complex component.

• Consistent Eig direction Trick Now, I know the sign of the eigenvector is usually immaterial (innumerable posts on this), however, I would like the signs to be consistent (because I am averaging the 1st eigenvector of each image.)

• My problem is that I have real and complex valued eigenvalues so I can't use the following Trick I read here that in order to have consistent signs, I can simply sum the elements of each eigenvalue, and then ensure that this sum is positive. How does one do the same for complex data? And is there some other way?

• Okay, What I am actually doing I'm putting this here so people can better see what I am doing in fuller detail:

As described here

• Step 1. solve eigenvalue problem I am basically finding eigenvectors called $$\alpha^{(1)}_k$$ for each image $$k$$, (the ones I wanted to ensure uniform sign), then

• Step 2. in order to find phi multiplying them by another complex vector, in order to find the principle component $$\phi^{(1)}_k$$ for each image $$k$$. Note that this is a complex vector for each $$k$$.

• Step 3. Averaging over k the $$\phi^{(1)}_k$$ But using a symmetry property (that I wont say because its unnecessary detail) before averaging makes the complex part go way (so that the average $$\langle \phi^{(1)}_k\rangle_k = \phi^{(1)}$$ is strictly real).

However, before Step 3, where I ultimately get a real valued, averaged $$Phi^{(1)}$$, I have the complex $$\alpha^{(1)}$$, which is the result of taking eigenvalues, and thats the part I want to be uniform sign for each image. And because they are complex, I can't just use the sum-components-positive trick. Any ideas how I can ensure consistent sign for each image?

• (1) Could you explain how PCA could produce a nonzero imaginary component? Regardless, you can always reframe the situation in terms of the real and imaginary parts of all your data and thereby deal only with real eigenvalues. (2) stats.stackexchange.com/questions/34396 likely holds the key to a solution.
– whuber
Aug 18, 2022 at 21:06
• (1) The correlation matrix $R(t,t')$ has imaginary components because the velocity data $\mathbf{u}$ which forms $R = \int u (t,r) u^* (t',r)\,dr$ was doubly fourier transformed in another spatial direction (its azimuthal direction $m$ and streamwise direction $k$). I omitted those details. (2) I can't pretend the imaginary part of the eigvecs $\alpha^{(1)}$ until I multiply by $u$ in equation (2.4) from the paper I posted Aug 18, 2022 at 21:11
• You don't have to omit anything: just express everything in terms of the real and imaginary components. I am baffled by what you might mean by the "sign" of a complex eigenvector, because even after normalization those vectors are indeterminate up to multiplication by any unit complex number, which consists of all those of the form $e^{2\pi i\theta}$ for $0\le\theta\lt 1.$ There is no well-defined "sign."
– whuber
Aug 18, 2022 at 21:13
• I don't disagree with you. In fact I was baffled how $\Phi^{(1)}_k$ could be uniquely determined, since it seems $\alpha^{(k)}$, from which they're formed, are not. Since I am to average the Phi's over $k$ and get a very specific graph, it seems they ought to be unique, otherwise the average would not be obtained..thats the paradox Aug 18, 2022 at 22:59

To ensure consistency for complex data, I summed each eigenvector, and then rotated that sum by $$e^{i \pi/2}$$ until both $$\mathfrak{Re}$$ and $$\mathfrak{Im}$$ were positive (first quadrant). This is equivalent to having the sum of a vector be positive ($$\mathbf{1}^T\mathbf{e}$$ > 0). My interpretation of the latter requirement (for real data) is a kind of rough integration - left rule quadrature - resulting in a positive integral.