The 2 covariance matrices only differ by values at top-right and bottom-left. However, sign of principal component eigen vectors (right column) has flipped.
import numpy as np
cov = np.array([[9369, 7060, 16469],
[7060, 8127, 23034],
[16469, 23034, 126402]])
eigenvalues, eigenvectors = np.linalg.eigh(cov)
print('Cov 1')
print(eigenvalues)
print(eigenvectors)
cov2 = np.array([[9369, 7060, *18969*],
[7060, 8127, 23034],
[*18969*, 23034, 126402]])
eigenvalues, eigenvectors = np.linalg.eigh(cov2)
print('Cov 2')
print(eigenvalues)
print(eigenvectors)
Results:
Cov 1
[ 1188.72951707 9507.3058357 133201.96464723]
[[-0.5549483 0.82002403 0.13997491]
[ 0.8280924 0.52849364 0.18696912]
[-0.07934332 -0.21967035 0.97234231]]
Cov 2
[ 1390.92828009 8581.02234156 133926.04937835]
[[-0.57175381 0.80502124 -0.15823521]
[ 0.817929 0.54427789 -0.18642352]
[-0.06395096 -0.23601353 -0.96964318]]
How can I either prevent this happening, or ‘correct’ in some way so that sign is same – either positive or negative in both cases?