SLIDE 6 legend([h(2) h(1)],’Binomial Estimated’,’Gaussian’); st = sprintf(’print -depsc CLTBinomial%04d’,np); eval(st); drawnow; %fprintf(’Pausing...\n’); pause; end;
Portland State University ECE 4/557 Decision Theory
23
Example 3: CLT Applied to Binomial RV
−3 −2 −1 1 2 3 0.1 0.2 0.3 0.4 0.5 PDF Estimate Normalized Binomial Histogram for z N:5000 NS:1000 Binomial Estimated Gaussian
Portland State University ECE 4/557 Decision Theory
21
Example 4: CLT Applied to Exponential RV
−5 −4 −3 −2 −1 1 2 3 4 5 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 PDF Estimate Normalized Exponential Sum Histogram for z N:1 NS:1000 Exponential Sum Estimated Gaussian
Portland State University ECE 4/557 Decision Theory
24
Example 3: MATLAB Code
function [] = CLTBinomial(); close all; FigureSet(1,’LTX’); NP = [2,5,10,20,30,100,1000,5000]; % No. histograms NS = 1000; % No. Samples p = 0.5; % Probability of 1 for cnt = 1:length(NP), np = NP(cnt); r = binornd(np,p,NS,1); % Random sample of NS sums mu = np*p; s2 = np*p*(1-p); z = (r-mu)/sqrt(s2); figure; FigureSet(1,’LTX’); Histogram(z,0.1,0.20); hold on; x = -5:0.02:5; y1 = 1/sqrt(2*pi).*exp(-x.^2/2); h = plot(x,y1,’r’); x2 = 0:np; y2 = binopdf(x2,np,p); x2 = (x2-mu)/sqrt(s2); %h = goodstem(x2,y2,’g’); %set(h,’LineWidth’,1.5); hold off; %set(gca,’XLim’,[-5 5]); st = sprintf(’Normalized Binomial Histogram for z N:%d NS:%d’,np,NS); title(st); box off; AxisSet(8); h = get(gca,’Children’);
Portland State University ECE 4/557 Decision Theory
22