Exercise Mean Acf

3
Statistical Signal processing 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;

description

Lab 1 of signals analisis

Transcript of Exercise Mean Acf

Page 1: Exercise Mean Acf

Statistical Signal processing

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;

Page 2: Exercise Mean Acf

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;

0 500 1000 1500 2000 2500 3000-5

0

5

White noise : x=0 2=1

Samples

Sam

ple

Valu

es

0 500 1000 1500 2000 2500 3000-2

0

2Mean

N

Main

Valu

es

-0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0 0.01 0.02 0.03 0.040

50Mean Experiment

N

Main

Valu

es

Page 3: Exercise Mean Acf

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/

II Exercise (Matlab exercise)

Generate N samples of a random process 𝑋[𝑛] by using the Wold representation, where the input process has a variance equal to 1 and the filter is a low pass filter of the Butterworth family. Use the Matlab function buttord to evaluate the filter order and the 3dB bandwidth. Choose different values of the following parameters:

Passband corner frequency

Stopband corner frequency

Passband ripple

Stopband attenuation and estimate the correlation and the sample periodogram. Compare the sample periodogram with the magnitude of the filter transfer function and interpret the obtained results for different values of 𝑁 and the Butterworth filter parameters.

0 1000 2000 3000 4000 5000 6000-1

0

1XCORR BIASED

Samples

Sam

ple

Valu

es

0 1000 2000 3000 4000 5000 6000-2

0

2

4XCORR UNBIASED

Samples

Sam

ple

Valu

es