Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use Matlab to verify the central limit theorem for the sum of N independent expo

ID: 1806971 • Letter: U

Question

Use Matlab to verify the central limit theorem for the sum of N independent exponential RVs (with a=0 and b=1) for N=5, 10 and 20

Explanation / Answer

clear; N_die=6; % 6 sided die N_roll=30; % 30 roll ensembles range=[1,N_die]; disp('Input N') N = input ('N: '); % total ensembles subplot (2,2,1) for m = 1:N; % L1=randint (1,N_roll, range); % first way to get random numbers L1=round (1+(N_die-1)*rand (N_roll, 1)); % second way for random numbers % hist(y,nb) draws a histogram with nb bins. hist(L1) axis([0 7 0 12]) % sets scaling for the x- and y title ('Random Distribution of 6 sided die numbers') xlabel('Random Integer', 'FontSize',8) ylabel('Frequency', 'FontSize',8) %num2str (m,p) converts the value of m to characters with p digits, cat(2,'a','b') concatenates a and b L5 (m)=mean (L1); % contains the mean of the L1 distribution str=cat(2, 'Mean (',num2str(m,4),') = ',num2str(L5(m),4)); %place the the value of the time and its mean on the screen, in red text(2,11,str,'Color','b'); %Change the color of the graph so that the bins are red and the edges of the bins are white. h = findobj(gca,'Type','Patch'); % change bin colors set(h,'FaceColor','r','EdgeColor','w') pause(0.5); end %L5; % at this point L5 is a distribution of means %figure %pause(2) subplot(2,2,2) hist(L5); % histogram title('Distribution of Means, and a Gaussian') xlabel('Mean','FontSize',8) ylabel('Frequency','FontSize',8) h = findobj(gca,'Type','Patch'); % change bin colors set(h,'FaceColor','b','EdgeColor','w') hold on ML=mean(L5);% this is the mean of the means ST=std(L5); % standard deviation of the means a=min(L5)-2.0; b=max(L5)+2.0; dx = (b-a)/100.0; x = [a:dx:b]; y =max(hist(L5))*exp(-(x-ML).^2); plot (x,y,'m:') % We next find the z-scores of each mean and plot these versus the means % We should get a straight line for a normal distribution => positive correlation pause(1) %figure subplot(2,2,3) z=(L5-ML)/ST; % z-scores % Also let's superimpose a line on this graph a=min(L5)-1; b=max(L5)+1; dx=(b-a)/100.0; x = [a:dx:b]; par=polyfit(L5,z,1); % actual line fit parameters str=cat(2,'fit:slope=',num2str(par(1))); %num2str(t) converts the value of par91) to characters, cat(2,'a','b') concatenates a and b y=polyval(par,x);% actual line fit plot (L5,z,'bo',x,y,'r:') % the z-scores plotted versus the means legend('data',str,4); grid on title('Correlation of the means and their Z-scores') xlabel('Means','FontSize',8) ylabel('Z-Scores','FontSize',8) h = findobj(gca,'Type','Patch'); % change bin colors set(h, 'FaceColor','b','EdgeColor','w')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote