Example_3_2#

Estimate the eigenvalues of a non-full rank matrix and its regulirized version.

import numpy as np
n_rows=5;
n_columns =7;
wlambda=1;
A=np.random.randn(n_rows,n_columns);
# Calculate eigenvalues with lambda=0
eigenvalues, _ = np.linalg.eig(2/n_rows*A.T@A)
print(eigenvalues)
[ 1.31676619e+01  9.24699069e+00  4.04156667e+00  2.72335139e+00
  1.01943370e+00  2.74643828e-16 -2.17648906e-16]
# Calculate eigenvalues with lambda=1
eigenvalues, _  = np.linalg.eig(2/n_rows*A.T@A+wlambda*np.eye(n_columns))
print(eigenvalues)
[14.16766186 10.24699069  5.04156667  3.72335139  2.0194337   1.
  1.        ]