Karhunen Loeve Expansion in Matlab

In summary, the conversation discusses the use of a Monte Carlo sampling method to generate a stochastic process with two random variables. The autocovariance matrix is calculated and its eigenvalues and eigenvectors are used to calculate a new variable, Y, which is the stochastic process in a base where the random variables are not correlated. However, the mean of Y does not match the mean of the original process, S. The individual is seeking guidance on potential errors in their approach.
  • #1
confused_engineer
39
2
Hello everyone.

I am trying to generate the KL expansion of a stochastic process. I use a Monte Carlo sampling method to generate the process, which involves two random variables and I compare it with it's theoretical mean for 50 values of time and they look quite similar. Then, I calculate the autocovariance matrix, from where I extract the eigenvalues and eigenvectors which are used to calculate the new variable Y which is the stochastic process S in a base where the random variables are not correlated. However, if I calculate the mean of Y it doesn't look like the the mean of S at all.

Can someone please tell me what am I doing wrong?
Thank you very much for reading.

clear
close all
V = unifrnd(1,2,1,10000);
A = betarnd(2,2,1,10000);
t=50;
for i=1:t
S(i,:)=V*i+0.5*A*i^2;
theoreticalmeanS(i)=3/2*i+1/4*i^2;
meanS(i)=mean(S(i));
end
for i=1:t
for j=1:t
AutocorrelationS(i,j)=(S(i,:)*S(j,:)')/10000;
AutocovarianceS(i,j)=(S(i,:)*S(j,:)')/10000-meanS(i)*meanS(j);
end
end

[eigenvectors, eigenvalues]=eig(AutocovarianceS);
eigenvalues_column=eig(AutocovarianceS);
Y=eigenvalues*S;Note: I am following the book of Alberto Leon Garcia (probability statistics and random processes for electrical engineering), pages 324-325.
 
Physics news on Phys.org
  • #2
Not sure if I can help here (I am extremely familiar with the core of MATLAB, but not with its stats toolbox, which you appear to be using), but let me ask a question: For the data sizes you're dealing with, is there a reason not to use SVD to give you the PCs and their weights directly, instead of going through the covariance intermediate and finding eigenvalues?

My reason for asking is partly just that, in theory and in my experience, SVD is more stable and well-behaved than EVD (and there are deep reasons for that). For instance, with round-off, you might have a complex eigenvalue for the covariance matrix; SVD is simply not capable of that.
 
  • #3
confused_engineer said:
for i=1:t
S(i,:)=V*i+0.5*A*i^2;
theoreticalmeanS(i)=3/2*i+1/4*i^2;
meanS(i)=mean(S(i));
end

What does ##S(i,k)## represent? The ##k## value of the ##i##th realization of the process? - or the ##i##th value of the ##k##th realization of the process? (If the process takes place in time, which index represents time?)
 

Related to Karhunen Loeve Expansion in Matlab

1. What is Karhunen Loeve expansion and how is it used in Matlab?

Karhunen Loeve expansion is a mathematical technique used for signal processing and data analysis. It is used in Matlab to decompose a signal or data set into a series of orthogonal basis functions, allowing for dimensionality reduction and noise reduction.

2. How does the Karhunen Loeve expansion differ from other dimensionality reduction techniques?

The Karhunen Loeve expansion is unique in that it uses the covariance matrix of the data to determine the orthogonal basis functions, rather than relying on predetermined basis functions like principal component analysis. This allows for a more customized and efficient decomposition of the data.

3. Can the Karhunen Loeve expansion be used for both real-valued and complex-valued data?

Yes, the Karhunen Loeve expansion can be used for both real-valued and complex-valued data. However, the implementation may differ slightly for complex-valued data in order to account for the additional dimensionality.

4. Are there any limitations to using the Karhunen Loeve expansion in Matlab?

One limitation of using the Karhunen Loeve expansion in Matlab is that it is most effective for stationary signals or data sets. Non-stationary data may require additional pre-processing or a different dimensionality reduction technique.

5. Can the Karhunen Loeve expansion be used for image data in Matlab?

Yes, the Karhunen Loeve expansion can be applied to image data in Matlab. However, since images are typically large and high-dimensional, it may be more computationally intensive and may require additional optimization techniques.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
645
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
810
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
907
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
Back
Top