Skip to content

Instantly share code, notes, and snippets.

@chris-taylor
Created September 27, 2012 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-taylor/3793275 to your computer and use it in GitHub Desktop.
Save chris-taylor/3793275 to your computer and use it in GitHub Desktop.
centrallimittheorem.octave
%Uniform distribution
x1 = randi(10,1000,1);
[n1 xout1] = hist(x1);
%Sum of uniform distribution
x2 = sum(randi(10,1000,12),2);
m = mean(x2);
s = std(x2);
[n2 xout2] = hist(x2);
%Plot figures
figure
bar(xout1,n1/1000)
export_fig('H:/matlab/histuniform.png')
figure
hold on
bar(xout2,n2/1000)
xs = 30:100
plot(xs,6*normpdf(xs,m,s),'r','LineWidth',2)
export_fig('H:/matlab/histnormal.png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment