function [z,pz] = mgnsum(X,P) % MGNSUM [z,pz] = mgnsum(X,P) Sum of n independent simple rv % Version of 5/16/96 % Distribution for the sum of n independent simple random variables % X an n-row matrix of X-values % P an n-row matrix of P-values % padded with zeros, if necessary % to make all rows the same length [n,r] = size(P); z = 0; pz = 1; for i = 1:n x = X(i,:); p = P(i,:); x = x(find(p>0)); p = p(find(p>0)); [z,pz] = mgsum(z,x,pz,p); end