📄 xplusy.m
字号:
%sumhisto.m/created by PJNahin for "Duelling Idiots"(2/25/99)
%This m-file produces 5,000 values of the sum of N random
%variables, each variable uniform from 0 to 1, and independent.
%It then plots a histogram of the sums using 100 bins.
%
%
rand('state',100*sum(clock))
clear z
N=input('How many random variables in a sum? ');
mean=N/2;
sd=sqrt(N/12);
for sumn=1:5000
s=0;
for i=1:N
s=s+rand;
end
s=(s-mean)/sd;
z(sumn)=s;
end
hist(z,100)
xlabel('sum')
ylabel('number of values per bin')
title('Histogram of the Sum of N Random Variables')
figure(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -