% gaussian white noise with var 1 N = 250; % how many samples? e = randn(N,1); % WN e(t) e1 = [0 ; e(1:end-1)]; % WN e(t-1) e2 = [ 0; 0; e(1:end-2)]; % WN e(t-2) % --------------------------------- % new stochastic process r. v. v = e + 2* e1 +e2; % expected value and variance estimation EXPv = mean(v); VARv = var(v); fprintf(1, ... ['Samples: %d \n',... 'Estimation of exp. value: %f \n',... 'Estimated variance: %f \n'],... N, EXPv, VARv); % ---------------------------------- figure; subplot(3,1,1); plot(e, '-bo', 'LineWidth',1.5,... 'MarkerEdgeColor','b',... 'MarkerFaceColor','b',... 'MarkerSize',8); grid on xlabel('time instants'); ylabel('gaussian white noise'); subplot(3,1,2) plot(v, '-rd', 'LineWidth',1.5,... 'MarkerEdgeColor','r',... 'MarkerFaceColor','r',... 'MarkerSize',8); grid on xlabel('time instants'); ylabel('stochastic process r. v.'); subplot(3,1,3); plot(e, '-bo', 'LineWidth',1.5,... 'MarkerEdgeColor','b',... 'MarkerFaceColor','b',... 'MarkerSize',8); hold on; plot(v, '-rd', 'LineWidth',1.5,... 'MarkerEdgeColor','r',... 'MarkerFaceColor','r',... 'MarkerSize',8); xlabel('time instants'); grid on