Created
September 27, 2012 10:12
-
-
Save chris-taylor/3793275 to your computer and use it in GitHub Desktop.
centrallimittheorem.octave
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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