Problem calculating eigenvalues and eigenvectors

Click For Summary
SUMMARY

The forum discussion centers on calculating eigenvalues and eigenvectors using the Karhunen-Loève expansion in Matlab, specifically with the script 2D_karhunen_loeve_identification_example.py. The user, Frank, encounters discrepancies between his computed eigenvalues and eigenvectors and those from sample data, suspecting that ignoring grid positions during covariance matrix calculation may be the cause. A suggestion is made to sort the output from the EIG function, as it does not return results in a specific order, which may resolve the issue.

PREREQUISITES
  • Understanding of Karhunen-Loève expansion
  • Familiarity with Matlab programming
  • Knowledge of covariance matrices
  • Experience with eigenvalue and eigenvector calculations
NEXT STEPS
  • Learn how to implement covariance matrix calculations in Matlab
  • Study the sorting of eigenvalues and eigenvectors in Matlab
  • Explore the implications of grid positions in data analysis
  • Investigate the Karhunen-Loève expansion in higher dimensions
USEFUL FOR

Researchers, data scientists, and engineers working with stochastic processes and dimensionality reduction techniques in Matlab.

Frank Einstein
Messages
166
Reaction score
1
Hello everyone. I am trying to construct a functioning version of randomfields (specifically 2D_karhunen_loeve_identification_example.py) in Matlab. For that, I have to calculate the Karhunen-Loève expansion of 2D data, since this is what it says in the documentation. I also have some sample data to test my results.
I have a matrix of size 144*7, being 144 the number of points, 5 the number of random variables and the first two, the X and Y points of each value. If I ignore the first two rows and calculate

[CODE lang="matlab" title="Eigenpair"][evec, eval]=eig(cov(realizations));
[/CODE]
the resulting eigenvectors and eigenvalues don't look at all like the ones of the sample data. I was wondering if this might happen because I am ignoring the grid positions at the time of calculating the covariance matrix.

Best regards.
Frank.

E. G. I will attach the stochastic realizations I have received and what I am expected to get
 

Attachments

  • 2D_sample_paths.txt
    2D_sample_paths.txt
    25 KB · Views: 206
  • 2D_identification_eigensolution_0.png
    2D_identification_eigensolution_0.png
    14.3 KB · Views: 200
  • 2D_identification_eigensolution_1.png
    2D_identification_eigensolution_1.png
    13.4 KB · Views: 217
  • 2D_identification_eigensolution_2.png
    2D_identification_eigensolution_2.png
    16.3 KB · Views: 191
  • 2D_identification_eigensolution_3.png
    2D_identification_eigensolution_3.png
    15.8 KB · Views: 199
  • 2D_identification_eigensolution_4.png
    2D_identification_eigensolution_4.png
    13.9 KB · Views: 214
Physics news on Phys.org
I'm struggling to understand your problem. What are the "grid positions" you're referring to?

I believe EIG does not return the eigenvalues / eigenvectors in any particular order. You may be comparing to a plot where they are sorted in order of descending eigenvalue magnitude.

Perform that sort and see if it improves your results.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 6 ·
Replies
6
Views
3K
Replies
11
Views
6K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K