Problem with Karhunen-Loève expansion in matlab

  • Context: MATLAB 
  • Thread starter Thread starter confused_engineer
  • Start date Start date
  • Tags Tags
    Expansion Matlab
Click For Summary
SUMMARY

The discussion focuses on performing the Karhunen-Loève (KL) expansion in MATLAB, specifically addressing the issue of obtaining zero-mean uncorrelated random variables. The user, identified as "Confused Engineer," implements the KL expansion using the eigenvalue decomposition of the covariance matrix of a transposed data matrix. Despite successfully computing the eigenvectors and confirming their orthonormality, the user encounters a problem where the means of the resulting variables, KLT, are not zero as theoretically expected. The user seeks clarification on this discrepancy.

PREREQUISITES
  • Understanding of Karhunen-Loève expansion
  • Familiarity with MATLAB programming
  • Knowledge of eigenvalue decomposition
  • Concept of covariance and variance in statistics
NEXT STEPS
  • Review MATLAB's documentation on the 'eig' function for eigenvalue decomposition
  • Learn about covariance matrix properties in the context of KL expansion
  • Explore methods to center data in MATLAB to achieve zero mean
  • Investigate the implications of eigenvector orthonormality in statistical analysis
USEFUL FOR

This discussion is beneficial for data scientists, statisticians, and MATLAB users interested in dimensionality reduction techniques and the theoretical foundations of the Karhunen-Loève expansion.

confused_engineer
Messages
34
Reaction score
1
TL;DR
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.

[CODE lang="matlab" title="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';[/CODE]

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

[CODE title="orthonormal eigenvectors"]V(:,2)'* V(:,1) %Eigenvectors
[/CODE]
returns zero and

[CODE title="orthonormal eigenvectors2"]V(:,2)'* V(:,2)
[/CODE]
returns one.

Also,
[CODE title="orthogonal RV"]
cov(KLT')[/CODE]

returns orthogonal results and

[CODE title="variance"]var(KLT')

[/CODE]
are the eigenvalues. However, if I writethe means aren't zero, as the theory says.

Can someone please tell me what am I doing wrong?

Best regards.
Confused Engineer.
 
Physics news on Phys.org
confused_engineer said:
However, if I writethe means aren't zero, as the theory says.

If you write... what? Exactly?
 
confused_engineer said:
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.

[CODE lang="matlab" title="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';[/CODE]

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

[CODE title="orthonormal eigenvectors"]V(:,2)'* V(:,1) %Eigenvectors
[/CODE]
returns zero and

[CODE title="orthonormal eigenvectors2"]V(:,2)'* V(:,2)
[/CODE]
returns one.

Also,
[CODE title="orthogonal RV"]
cov(KLT')[/CODE]

returns orthogonal results and

[CODE title="variance"]var(KLT')

[/CODE]
are the eigenvalues. However, if I writethe means aren't zero, as the theory says.

Can someone please tell me what am I doing wrong?

Best regards.
Confused Engineer.

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

Similar threads

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