Professional Documents
Culture Documents
Statistical Signal Processing: I Exercise (Matlab Exercise)
Statistical Signal Processing: I Exercise (Matlab Exercise)
Statistical Signal Processing: I Exercise (Matlab Exercise)
Lab. 2
I Exercise (Matlab exercise)
Generate 1000 samples of a zero mean stationary Gaussian random process [] with variance
equal to 1.
clear all; clc; close all;
L=3000; %Sample length for the random signal
mu=0;
sigma=1; % variance is sigma**2
X=sigma*randn(L,1)+mu;
figure();
subplot(4,1,1)
plot(X);
title(['White noise : \mu_x=',num2str(mu),' \sigma^2=',num2str(sigma^2)])
xlabel('Samples')
ylabel('Sample Values')
grid on;
Extract N samples of the process in the interval (0, 1) for N =1,2,...,1000 and estimate
the mean of the process [] for each value of N. Plot the estimated mean as a function
of N.
M=zeros(1,L);
for i= 1 :1: L
NP=[1:i];
for y= 1:1:i
XX(y)=X(y);
end
M(i)=mean(XX);
end
subplot(4,1,2)
plot(1:1:L, M);
title('Mean')
xlabel('N')
ylabel('Main Values')
grid on;
Fix = 1000 and repeat the experiment of estimating the mean several times (for
example, do 200 experiments) and draw the histogram of the results (use the Matlab
function hist)
subplot(4,1,3)
%plot(1:1:mean_experiment_constant, mean_experiment);
hist(mean_experiment);
title('Mean Experiment')
xlabel('N')
ylabel('Main Values')
grid on;
Sample Values
Main Values
Main Values
500
1000
500
1000
1500
Samples
Mean
2000
2500
3000
1500
2000
N
Mean Experiment
2500
3000
2
0
-2
50
0
-0.06
-0.05
-0.04
-0.03
-0.02
-0.01
N
0.01
0.02
0.03
0.04
With = 1000 estimate the correlation using xcorr (compare the results obtained with
the two options biased and unbiased)
xcorr_biased=xcorr(X,X,'biased');
figure(2)
subplot(3,1,1)
plot(xcorr_biased);
title('XCORR BIASED')
xlabel('Samples')
ylabel('Sample Values')
grid on;
xcorr_unbiased=xcorr(X,X,'unbiased');
subplot(2,1,2)
plot(xcorr_unbiased);
title('XCORR UNBIASED')
xlabel('Samples')
ylabel('Sample Values')
grid on;
Sample Values
XCORR BIASED
1
0
-1
1000
2000
3000
Samples
4000
5000
6000
4000
5000
6000
XCORR UNBIASED
Sample Values
-2
1000
2000
3000
Samples
http://web.ntpu.edu.tw/~yshan/chapter6_han.pdf
http://web.stanford.edu/class/ee179/handouts/slide24.pdf
http://www.gaussianwaves.com/2013/11/simulation-and-analysis-of-white-noise-in-matlab/