onewaytodoit.m
来自「一些常被用于教学或者参考的概率论的实例的源代码」· M 代码 · 共 22 行
M
22 行
%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 + =
减小字号Ctrl + -
显示快捷键?