% Central Limit Theorem %
x=randn(1000,1);
S(1)=0;
for k=2:1000; S(k)=S(k-1)+x(k); end;
n=1:1000;
comet(n,S); pause;
comet(n,S./n); pause;
comet(n,S./sqrt(n)); pause;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
for n=1:2:100; x=0:n;
p=gamma(n+1)./gamma(x+1)./gamma(n-x+1).*(0.3).^x.*(0.7).^(n-x);
plot(x,p); title('Binomial probabilities for increasing values of n'); pause(1); end; pause;
%%%%%%%%%%%%%%%%%%%%%%%%%%%
X=rand(100,300)-0.5;
hist(X(1,:)); title('Histogram of X'); pause
hist(sum(X(1:5,:))/sqrt(5)); title('Histogram of the 5-th partial sums'); pause
hist(sum(X(1:25,:))/sqrt(25)); title('Histogram of the 25-th partial sums'); pause
hist(sum(X(1:100,:))/sqrt(100));title('Histogram of the 100-th partial sums');