Problem calculating eigenvalues and eigenvectors

1 reply · 2K views · last reply
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: 242
  • 3D surface plot titled Eigensolution #0 (λ0 = 18.27), with x1 and x2 axes ranging 0 to 10 and a vertical axis labelled φ(x) from about -0.15 to 0.20, coloured with a rainbow gradient.
    2D_identification_eigensolution_0.png
    14.3 KB · Views: 239
  • 3D surface plot titled Eigensolution \#1 (λ1 = 14.26), showing a smooth wavy surface over x1 and x2 axes from 0 to 10, with values ranging from -0.2 to 0.2 on the vertical axis labeled φ(x).
    2D_identification_eigensolution_1.png
    13.4 KB · Views: 258
  • 3D surface plot titled Eigensolution #2 (λ2 = 7.03), with axes x1 and x2 from 0 to 10 and vertical axis φ(x) ranging from about -0.3 to 0.2, showing a smooth surface with a red peak and a blue trough.
    2D_identification_eigensolution_2.png
    16.3 KB · Views: 235
  • 3D surface plot titled Eigensolution #3 (λ3 = 0.84), with axes x1 from 0 to 10, x2 from 0 to 10 and φ(x) from -0.2 to 0.3, showing a smooth wavy surface.
    2D_identification_eigensolution_3.png
    15.8 KB · Views: 235
  • 3D surface plot titled Eigensolution #4 (λ4 = 0.00), with x1 and x2 axes from 0 to 10 and a vertical axis labelled φ(x) ranging from about -0.4 to 0.4, showing a saddle-shaped surface.
    2D_identification_eigensolution_4.png
    13.9 KB · Views: 257
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.