TOPIC = CENTRAL LIMIT THEOREM. CLASS = PROBABILITY ONLY NEED A MATLAB CODE. PLEA
ID: 1996221 • Letter: T
Question
TOPIC = CENTRAL LIMIT THEOREM.
CLASS = PROBABILITY
ONLY NEED A MATLAB CODE. PLEASE IF YOU HAVE KNOWLEDGE ABOUT PROBABILITY AND RANDOM SIGNAL AND MATLAB HELP ME.
MANY THANKS FROM NOW ON.
1) Create N random variables (X XN) each with L samples. These should be independent and identically distributed. Generate Sn, which will be the sum of these random variables. 2) Find the mean and variance of X e. Hand o2. Since the RV's are iid's, H will be the mean of all the other RV's in this set too. You can verify this by finding the mean of a few other variables 3) Create the random variable Zn by adding N random variables as nH. 4) Plot the pdf of Zn 5) Repeat steps 3 and 4 for N-10, N-50 and N 100. For each case, repeat for values of L 100, 1000, 10,000 and 1000,000 6) Comment on the effects of the various values of Land N. 7) Repeat for each of the three RV's listed below: Uniform random variable Exponential random variable (lambda 0.5) Gaussian random variable (mu 5, sigma 2)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')
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.