Statistical Properties of Eigenvalues

55 Views Asked by At

While playing around with some numpy and a random number generator, I found this odd bit. I set up a function to generate a matrix of some size and fill it with pseudorandom integers. Then, using numpy, I computed and stored the eigenvalues and the magnitude of the eigenvectors. Last I ran some elementary statistical data on the results. I found that no matter how large the matrix seems to be or how much variance there is in the number generator, the eigenvalues seem to always come out random (which I expected) but the eigenvector magnitude seem to converge to some value with an incredibly low standard deviation and a low variance. This is the code I ran:

def buildMatrix(size, a, b):
  matrix = []
  for i in range(size):
    row = [random.randint(a, b) for j in range(size)]
    matrix.append(row)
  
  return np.array(matrix)


def statPrint(arr):
  print(f"Average: {np.average(arr)}")
  print(f'Mean: {np.mean(arr)}')
  print(f'Meadian {np.median(arr)}')
  print(f'Variance: {np.var(arr)}')
  print(f'STD: {np.std(arr)}')
eigenlist = np.array([])
vectormag = np.array([])
run = 1
terminate_num = 400
for i in range(1, terminate_num):
  newMatrix = buildMatrix(10, -10,10)
  # try:
  eigenvals, eigenvecs = np.linalg.eig(newMatrix)
  magnitude = np.linalg.norm(eigenvecs)
  vectormag = np.append(vectormag, magnitude)
  # except np.linalg.LinAlgError:
  #   eigenset = np.array([0])
  eigenlist = np.append(eigenlist, eigenvals)
if eigenlist.size == 0:
  print("List of eigenvalues is empty")
else:
  print('Eigenvalue stats are')
  statPrint(eigenlist)
print('')
if vectormag.size == 0:
  print("List of vector magnitude list is empty")
else:
  print('Vector Magnitude stats are')
  statPrint(vectormag)

and there are the result for this particular run:

Eigenvalue stats are
Average: (0.01503759398496242+8.904044307770679e-18j)
Mean: (0.01503759398496242+8.904044307770679e-18j)
Meadian (0.10265133222001888-9.299531440867117j)
Variance: 198.33634998888684
STD: 14.083193884516637

Vector Magnitude stats are
Average: 3.1622776601683786
Mean: 3.1622776601683786
Meadian 3.1622776601683795
Variance: 6.840748701916543e-31
STD: 8.270881876750836e-16

Now when you change the matrix, the eigenvectors do change, but the variance is similarly very low. And the change isnt all that much considering that I have run ranges from [-10, 10]. Is there any particular reason this happens mathematically?

1

There are 1 best solutions below

3
On BEST ANSWER

Can you give some more details? I am a little confused why you are asking this, since I think the eigenvector magnitude is sort of irrelevant. Specifically, an eigenvalue/vector pair satisfies $$Av = \lambda v.$$ In particular, suppose you multiply both sides of the equation above by a constant, say $c$. Then this equation still holds, as in $$A (cv) = \lambda (cv).$$ The point being that the norm of the eigenvector is sort of irrelevant, i.e. if $v$ is an eigenvector, then $c$ is one as well.

Typically in linear algebra, this is why we usually only care about the eigenvalues. We do care about the eigenvectors, but we usually care about what "directions" they span, we don't care about their actual norm (since an eigenvector will remain an eigenvector even if it is scaled; but note that all multiples of the eigenvector span a line, so you can think of an eigenvector as determining a unique line, or direction, not a magnitude).

Perhaps numpy is standardizing it so that all of the eigenvectors are the same length (since again, the only relevant thing is their direction, not their length).