Central limit theorem understanding N

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?

回答 (3 件)

KSSV
KSSV 2016 年 11 月 24 日

0 投票

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 件のコメント

Aldo
Aldo 2016 年 11 月 24 日
How come I still get normal distribution even if N = 1, shouldn't all ´have the same probability?
KSSV
KSSV 2016 年 11 月 24 日
It is the M which matters...

サインインしてコメントする。

Star Strider
Star Strider 2016 年 11 月 24 日

0 投票

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.)
faruk bo
faruk bo 2018 年 12 月 3 日

0 投票

You should use mean function instead of cumsum. cumsum function isn't appropriate for CLT.

質問済み:

2016 年 11 月 24 日

回答済み:

2018 年 12 月 3 日

Community Treasure Hunt

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

Start Hunting!

Translated by