Central limit theorem understanding N
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
M = 1e3;
N = 4;
mu = 5;
X = exprnd(mu, M, N);
S = cumsum(X, 2);
for k = 1:N
hist(S(:, k), 30)
xlabel(num2str(k))
pause(0.1)
end
I am trying to understand this code, so my question is what does N represent. And what happens when N is increased or decreased? Why is that?
0 comentarios
Respuestas (3)
KSSV
el 24 de Nov. de 2016
Central limit theorem states that, when independent random variables are added, their sum tends toward a normal distribution commonly known as a bell curve.
In the code exprnd(mu, M, N), generates a random numbers of size MXN with mean mu. The theorem states that as the number of random numbers approaches infinity their sum fits to normal distribution.
In your code, you can change N vlaues too. Chekc this code.
clc ; clear all ;
M = 1e3;
N = 4;
mu = 5;
X = exprnd(mu, M, N);
S = cumsum(X, 2);
for k = 1:N
hist(S(:, k), 30)
hold on
histfit(S(:,k),30)
hold off
xlabel(num2str(k))
drawnow
pause(0.1)
end
2 comentarios
Star Strider
el 24 de Nov. de 2016
The ‘X’ matrix is an (MxN) matrix of exponentially-distributed numbers. The code as written does not illustrate the Central Limit Theorem. This version of it approaches the normal distribution with increasing values of ‘M’:
M = 1e3;
N = 4;
mu = 5;
X = exprnd(mu, M, N);
S = cumsum(X, 2);
hist(S(:,4), 30)
I invite you to explore the Central Limit Theorem on your own, with your own code, so you understand how it works. The convolution (the conv function) can be helpful in understanding the Central Limit Theorem and the statistical properties of probability distributions. (It’s late here and I’m tired, so I’ll leave you to explore that on your own.)
0 comentarios
faruk bo
el 3 de Dic. de 2018
You should use mean function instead of cumsum. cumsum function isn't appropriate for CLT.
0 comentarios
Ver también
Categorías
Más información sobre Model Statistics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!