# Confused about Karhunen-Loeve Transform

74 views (last 30 days)
Kyle on 26 Sep 2011
Hi all, I've read lots of documents about KLT, but still get confused on how to correctly apply it to a data set. My references:
To sum up about the first link, the step to calculate the KLT of a matrix x = [x1(t); x2(t); x3(t), ... xn(t)] in which xn(t) is a time series
Step1: auto-correlation matrix--> R = x*x';
Step2: calculate transformation matrix Phi_H--> [V,D] = eig( R); Phi_H = V';
Step3: transformed matrix--> y = Phi_H * x
Then apply this algorithm to the example at link2, to transform a matrix x = [1 2 4; 2 3 10]; The transformation matrix is not right according to that done by Mathematica, neither does the final result.
Could anyone please revise my algorithm applying to transform a time-series matrix?
Thank you for any suggestions Kyle
##### 2 CommentsShowHide 1 older comment
Kyle on 27 Sep 2011
They are really similar, wiki states that KLT is "also called" SVD. In some code SVD removes the mean, but I think KLT doesn't need this step.

UJJWAL on 26 Sep 2011
Edited: Walter Roberson on 24 Aug 2015
Ok.... Let me put it down one by one...
Karhunen Loeve Transform relies on the covariance matrix of a set of observation vectors. The basic Algorithm is clearly explained in the first link you have posted. I am below giving the code for the KLT for the same example as given in the MATHEMATICA Example which you have mentioned :-
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';
Note the following points :-
a) For a given Eigenvalue there can be multiple EigenVectors which will be multiples of each other. Now if you run the program then please observe the following points :-
(i) Take a look at the transformation matrix returned by mathematica and the matrix V(which is the same as the transformation matrix returned by MATLAB). They are essentially the same except that one of the eigenvectors has been multiplied by -1 which is perfectly acceptable because even by multiplication by -1 it is still an eigenvector. It is this difference in the transformation matrices used by the two softwares that results into different values of the KVT. Also note that one of the eigenvectors in both the softwares is the same and so is one of the rows in the KVT. So Essentially the difference is there just because of the multiplication by -1 and there is nothing to worry about these results. If mathematics allows it then nothing can refute that.
(ii) Also note that in MATHEMATICA the observations are taken row-wise while in MATLAB they are taken Column-wise.It is because of that I have transposed y in the above code.
Please remember that each software calculates a quantity by a certain algorithm and minute differences may arise. The only important thing is mathematical consistency. Hope this clears your doubt.
Happy To help.
UJJWAL
##### 2 CommentsShowHide 1 older comment
Jaime De La Mota Sanchis on 27 May 2021
As far as I understand, the KLT should be orthogonal, but as far as I can tell, they aren't. Am I wrong?

### Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by