z.m
来自「一些常被用于教学或者参考的概率论的实例的源代码」· M 代码 · 共 23 行
M
23 行
%z.m/created by PJNahin for "Duelling Idiots"(2/15/99)
%This m-file simulates the random variable Z=X/(X-Y),
%where X and Y are independent and uniform from 0 to 1.
%The output is a histogram of Z.
%
%
rand('state',100*sum(clock));
x=-3:.05:3;
index=10000;
while index>0
X=rand;
Y=rand;
Z=X/(X-Y);
if abs(Z)<3
vector(index)=Z;
index=index-1;
end
end
hist(vector,x)
title('Fig.12.4 - Histogram of Z=X/(X-Y)')
xlabel('z, in bins of width 0.05')
ylabel('number of numbers in each bin')
figure(1)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?