Understanding Unique Value Problems in Python

Asked 2 years ago, Updated 2 years ago, 17 views

We believe that we obtained a diagonal matrix by converting the following data (matrix of 5, 10).
However, I am troubled because I can't get a diagonal matrix.

Is there anything wrong?Thank you for your cooperation.

program

Think about the unique value of #data
# correlation matrix R
R=np.corrcoef(data)
# eigenvalues, eigenvectors
w,C = LA.eig(R)

# Find the data_z converted directly from data
data_z=np.array([])
for i in range (10):
    z=np.dot(C,np.transpose(data[:,i]))
    data_z=np.append(data_z,z)
data_z = data_z.reshape(10,5)

# I want to find the diagonal matrix r
# However, r does not form a diagonal matrix
r=np.dot(z_,np.transpose(z_))

Target Data

#data
array([-1.43536081, 0.31672281, -0.08760418, -0.7614825, -0.02021635,
         1.46231594,  1.66447944,  0.58627413, -1.36797298, -0.35715551],
       [-1.40345563, -0.35240956,  1.50237761, -0.4142358 , -1.77441306,
         1.06959394,  0.08037411,  1.0077677 , -0.10510461,  0.38950531],
       [-1.53225887,  0.21367519,  0.18593929, -0.76816204, -0.34940435,
         1.53962792,  1.51869003,  0.71822383, -1.26428114, -0.26204986],
       [-1.37462585,  0.27390587, -0.1306024 , -0.77267902, -0.0641876 ,
         1.49846638,  1.72660423,  0.55160401, -1.31623701, -0.39224862],
       [-1.39815422, -0.36117539,  1.51740696, -0.42272585, -1.75938822,
         1.07351947,  0.07160888,  1.01038282, -0.11428387,  0.38280943]])

python

2022-09-29 22:03

1 Answers

There are multiple issues.

  • data is an unorthodox matrix.An eigenvalue must be a square matrix before it exists, and other concepts such as singular values are used for an unorthodox matrix.In particular, numpy.linalg.eig is expected to be used for square matrices.
  • The
  • code treats the eigenvector of the correlation matrix R as if it were the eigenvector of data.
  • If you want all the eigenvalues in the first place, align them with diagonal elements and you'll get diagonalized.


2022-09-29 22:03

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.