<< Chapter < Page | Chapter >> Page > |
This could, of course, have been achieved by using icalc and csort, which has the advantage that other functions of X and Y may be handled. Also, since the random variables are nonnegative, integer-valued, the MATLAB convolution function may beused (see [link] ). By repeated use of the function mgsum, we may obtain the distribution for the sum of more than two simple random variables. Them-functions mgsum3 and mgsum4 utilize this strategy.
The techniques for simple random variables may be used with the simple approximations to absolutely continuous random variables.
The moment generating functions for the uniform and the symmetric triangular show that the latter appears naturally as the difference of two uniformly distributed randomvariables. We consider X and Y iid, uniform on [0,1].
tappr
Enter matrix [a b]of x-range endpoints [0 1]
Enter number of x approximation points 200Enter density as a function of t t<=1
Use row matrices X and PX as in the simple case[Z,PZ] = mgsum(X,-X,PX,PX);plot(Z,PZ/d) % Divide by d to recover f(t)
% plotting details --- see
[link]
The generating function
The form of the generating function for a nonnegative, integer-valued random variable exhibits a number of important properties.
In [link] , above, we establish the generating function for Poisson from the distribution. Suppose, however, we simply encounter the generating function
From the known power series for the exponential, we get
We conclude that
which is the Poisson distribution with parameter .
For simple, nonnegative, integer-valued random variables, the generating functions are polynomials. Because of the product rule (T2) , the problem of determining the distribution for the sum of independentrandom variables may be handled by the process of multiplying polynomials. This may be done quickly and easily with the MATLAB convolution function.
Suppose the pair is independent, with
In the MATLAB function convolution, all powers of s must be accounted for by including zeros for the missing powers.
gx = 0.1*[2 3 3 0 0 2]; % Zeros for missing powers 3, 4gy = 0.1*[0 2 4 4]; % Zero for missing power 0gz = conv(gx,gy);
a = [' Z PZ'];
b = [0:8;gz]';
disp(a)Z PZ % Distribution for Z = X + Y
disp(b)0 0
1.0000 0.04002.0000 0.1400
3.0000 0.26004.0000 0.2400
5.0000 0.12006.0000 0.0400
7.0000 0.08008.0000 0.0800
If mgsum were used, it would not be necessary to be concerned about missing powers and the corresponding zero coefficients.
Notification Switch
Would you like to follow the 'Applied probability' conversation and receive update notifications?