based on problem 385 from leonGarcia 08 use octave Matlab or
(based on problem 3.85 from leon-Garcia \'08)
use octave, Matlab or C to generate 200 pairs of numbers (X_i, Y_i), in which a the component are independent and each component is uniform in the set {1,2,.....,9,10}.
(a) Plot the relative frequencies of the X and Y outcomes.
(b) plot the relative frequencies of the random variable Z= X+Y. can you discern the pmf of Z?
(c) Plot the relative frequencies of W = XY. can you discern the pmf of Z?
(d) Plot the relative frequencies of V= X/Y. Is the pmf discernable?
Solution
(a) k = [1:10];
pk = ones(1,10)./10;
Sx = discrete_rnd(200, k, pk);
Sy = discrete_rnd(200, k, pk);
figure;
hist(Sx, k);
figure;
hist(Sy, k)
(b) Sz = Sx + Sy;
figure;
hist(Sz, [2:20]);
(C) Sw = Sx .* Sy;
figure;
hist(Sw, 10);
(D) Sv = Sx ./ Sy;
figure;
hist(Sv, 10);
