Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

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

1 vue (au cours des 30 derniers jours)
Ibnul Jaif Farabi
Ibnul Jaif Farabi le 8 Déc 2016
Clôturé : John D'Errico le 8 Déc 2016
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');

Réponses (0)

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by