Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How can I use this following script to demonstrate central limit theorem?

1 回表示 (過去 30 日間)
Ibnul Jaif Farabi
Ibnul Jaif Farabi 2016 年 12 月 8 日
閉鎖済み: John D'Errico 2016 年 12 月 8 日
clear
sim_length = 20*1000; %number of samples
N = 5;
X = -1 + 2*rand(N, sim_length); % generate N times 20000 ... uniformely distributed random variable matrix over (-1,1)
Z = sum(X); % take the column sum to obtain Z = \sum {n=1}ˆ5 X n
step = 0.04;
nbins = -10:step:10;
[Zd, y]= hist(Z,nbins); % generating histogram
pdf_Z = Zd/(sim_length*(step));
M = mean(Z); % evaluating mean of Z
V = var(Z); % evaluating variance of Z
Gd = 1/(sqrt(2 *pi * V))*exp(-0.5*(y - M).^2/V); % Gaussian ... distribution with same mean and varinace of Z
plot(y, pdf_Z,'o','color',[0 0 1]);
hold on;
plot(y, Gd,'-','color',[1 0 0]);
legend ('PDF of Z','Gaussian PDF');

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by