# correlation matrix for complex white noise does not equal to identity matrix?

I generate 8 time series of gaussian white noise and want to compute the correlation matrix at a frequency bin between them. The following is the matlab code I use

clear all;
close all;

fs = 4000;
N = 100*fs;
R = 0.5;% overlap percent
Nseg = fs;

M = 8;

for m = 1:M
x(:,m) = randn(N,1) ;
end

segNum = floor((N-R*Nseg)/((1-R)*Nseg));

for n = 1:segNum
y = x([1:Nseg]+(n-1)*Nseg*(1-R),:) ;

Y = fft(y);

RR(n,:,:) = transpose(Y(300,:))*conj(Y(300,:));

end

R_hat = 0;
for n = 1:100
R_hat = R_hat + squeeze(RR(n,:,:));
end

R_hat = R_hat/100;


However, the estimated correlation matrix $$R_{hat}$$ does not equal to identity matrix. Can you help point out what the problem is with my code?

Why don't you simply compute $$X^{H} X / N$$ ?

clear all;
close all;

fs = 4000;
N = 100*fs;
R = 0.5;% overlap percent
Nseg = fs;

M = 8;


I noticed your data was not complex, since you metioned complex in the question here I made it complex.

X = 0.5*randn(N,M) + 0.5j *randn(N,M);


This will be close to the identity matrix there will be small complex perturbations the expected perturbations are inversely proportional to $$\sqrt{N}$$. The $$X^H$$ corresponds to X', it is the conjugate transpose of $$X$$.

R_hat = X' * X / N


### Edit

Here I compute RR such that RR(:,:,k) is the accumulated covariance matrix of the frequency bin $$k$$ for the different inputs.

clear all;
close all;

fs = 4000;
N = 100*fs;
R = 0.5;% overlap percent
Nseg = 256;

M = 8;

for m = 1:M
x(:,m) = randn(N,1) ;
end

segNum = floor((N-R*Nseg)/((1-R)*Nseg));

RR = zeros(M, M, Nseg);

for n = 1:segNum
y = x([1:Nseg]+(n-1)*Nseg*(1-R),:) ;
Y = fft(y);
for k = 1:Nseg
%% the correlation for for one bin one slice.
RR(:,:,k) = RR(:,:,k) + Y(k, :)' * Y(k, :);
end
end
%% Normalize
RR = RR * (1/segNum/Nseg);

%% Acculate over all bins
R_hat = 0;
for n = 1:Nseg
R_hat = R_hat + RR(:,:,k);
end

R_hat = R_hat/Nseg

• Thank you for the answer. Actually, I am caculating the cross spectral density matrix at a frequency bin. The data is complex instead of real because we are manipulating in frequency domain. When it is done in time domain, such as x'x, the estimated correlation matrix is equal to identity matrix. – ecook Mar 12 at 8:04