Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

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

1 visualización (últimos 30 días)
Ibnul Jaif Farabi
Ibnul Jaif Farabi el 8 de Dic. de 2016
Cerrada: John D'Errico el 8 de Dic. de 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');

Respuestas (0)

La pregunta está cerrada.

Community Treasure Hunt

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

Start Hunting!

Translated by