Problem with Karhunen-Loève expansion in matlab

  • #1
TL;DR Summary
I want to perform the KL expansion in Matlab, but I cannot calculate the zero-mean uncorrelated random variables
I have copied the code of the accepted answer to this post in the official Matlab forums, since I am interested in performing the KL expansion myself.

Calculation of random variables:
clc

clear all

y=[1,2,4;2,3,10];

y=y' %Reasons for transposing will become clear when you will read the second point given below.

[V,D]=eig(cov(y))

KLT = V' * y';

As far as I understand, the vector defined in the last line, KLT are the uncorrelated random variables. The eigenvectors are certainly orthnormal since

orthonormal eigenvectors:
V(:,2)'* V(:,1) %Eigenvectors
returns zero and

orthonormal eigenvectors2:
V(:,2)'* V(:,2)
returns one.

Also,
orthogonal RV:
cov(KLT')

returns orthogonal results and

variance:
var(KLT')
are the eigenvalues. However, if I write


the means aren't zero, as the theory says.

Can someone please tell me what am I doing wrong?

Best regards.
Confused Engineer.
 
  • #3
Summary:: I want to perform the KL expansion in Matlab, but I cannot calculate the zero-mean uncorrelated random variables

I have copied the code of the accepted answer to this post in the official Matlab forums, since I am interested in performing the KL expansion myself.

Calculation of random variables:
clc

clear all

y=[1,2,4;2,3,10];

y=y' %Reasons for transposing will become clear when you will read the second point given below.

[V,D]=eig(cov(y))

KLT = V' * y';

As far as I understand, the vector defined in the last line, KLT are the uncorrelated random variables. The eigenvectors are certainly orthnormal since

orthonormal eigenvectors:
V(:,2)'* V(:,1) %Eigenvectors
returns zero and

orthonormal eigenvectors2:
V(:,2)'* V(:,2)
returns one.

Also,
orthogonal RV:
cov(KLT')

returns orthogonal results and

variance:
var(KLT')
are the eigenvalues. However, if I write


the means aren't zero, as the theory says.

Can someone please tell me what am I doing wrong?

Best regards.
Confused Engineer.

If you write... what? Exactly?
Sorry, if I write mean(KLT')
 

Suggested for: Problem with Karhunen-Loève expansion in matlab

Replies
2
Views
2K
Replies
4
Views
501
Replies
4
Views
935
Replies
2
Views
1K
Replies
6
Views
744
Replies
2
Views
970
Replies
5
Views
1K
Replies
1
Views
659
Replies
1
Views
891
Back
Top