x=[-10:10] >>normpdf(x,0,1)' ans = 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0001 0.0044 0.0540 0.2420 0.3989 0.2420 0.0540 0.0044 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 W= [0.0001 0.0044 0.0540 0.2420 0.3989 0.2420 0.0540 0.0044 0.0001] plot(Y+mu_0,'.'); mu=convn(Y,W,'same'); hold on plot(mu+mu_0,'-') normpdf(x,0,9)' ans =Y 0.0239 0.0269 0.0299 0.0328 0.0355 0.0380 0.0402 0.0419 0.0432 0.0441 0.0443 0.0441 0.0432 0.0419 0.0402 0.0380 0.0355 0.0328 0.0299 0.0269 0.0239 W=[ 0.0328 0.0355 0.0380 0.0402 0.0419 0.0432 0.0441 0.0443 0.0441 0.0432 0.0419 0.0402 0.0380 0.0355 0.0328] >> sum(W) ans = 0.5957 W=W/sum(W) >>sum(W) ans = 1 >>normpdf(x,0,1/2)' ans = 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0003 0.1080 0.7979 0.1080 0.0003 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 W=[ 0.0003 0.1080 0.7979 0.1080 0.0003] >>sum(W) ans = 1.0145 >>W=W/sum(W) ans = 0.0003 0.1065 0.7865 0.1065 0.0003 normpdf(x,0,1/4)' ans = 0 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0005 1.5958 0.0005 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0 W=[0.0005 1.5958 0.0005] >>W=W/sum(W) W = 0.0003 0.9994 0.0003 >>normpdf(x,0,1/9)' .... 0.0000 3.5905 0.0000 0.0000 .... W=1 %Kernel density estimation for unemployment rate data X=unemployment; >> min(X) ans = 3.9000 >> max(X) ans = 10.8000 >> mean(X) ans = 6.6913 y=[0:0.1:14]; pdf=zeros(length(y),1/9); for i=1:length(y) pdf(i)= sum(normpdf(y(i)-X,0,1)); end; pdf=pdf/252 >> sum(0.1*pdf) ans = 1.0000 plot(y,pdf,'-'); y=[0:0.1:14]; pdf=zeros(length(y),1); for i=1:length(y) pdf(i)= sum(normpdf(y(i)-X,0,1)); end; pdf=pdf/252 >> sum(0.1*pdf) ans = 1.0000 y=[0:0.1:14]; pdf=zeros(length(y),1); for i=1:length(y) pdf(i)= sum(normpdf(y(i)-X,0,4)); end; pdf=pdf/252 >> sum(0.1*pdf) ans = 0.9025