Central limit theorem understanding N

조회 수: 7 (최근 30일)
Aldo
Aldo 2016년 11월 24일
답변: faruk bo 2018년 12월 3일
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일
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일
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일
You should use mean function instead of cumsum. cumsum function isn't appropriate for CLT.

카테고리

Help CenterFile Exchange에서 Model Statistics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by