📄 onewaytodoit.m
字号:
%onewaytodoit.m/created by PJNahin for "Duelling Idiots"(2/28/99)
%This m-file plots a histogram of 10,000 random numbers
%that are normally distributed with zero mean and unit variance.
%
%
rand('state',100*sum(clock)); %new seed for generator;
scale=2*pi;
for i=1:2:10000
u=rand;
theta=scale*rand;
factor=sqrt(-2*log(u));
x1=factor*cos(theta);
x2=factor*sin(theta);
y(i)=x1;
y(i+1)=x2;
end
hist(y,100) %plot histogram of y using 100 bins;
title('Histogram of a Normal Random Number Generator')
xlabel('100 bins, 10,000 numbers')
ylabel('number of numbers in each bin')
figure(1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -