%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) 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)