<< Chapter < Page Chapter >> Page >

Compound demand

The following pattern provides a useful model in many situations. Consider

D = k = 0 N Y k

where Y 0 = 0 , and the class { Y k : 1 k } is iid, independent of the counting random variable N . One natural interpretation is to consider N to be the number of customers in a store and Y k the amount purchased by the k th customer. Then D is the total demand of the actual customers. Hence, we call D the compound demand .

gend.m Uses coefficients of the generating functions for N and Y to calculate, in the integer case, the marginal distribution for the compound demand D and the joint distribution for { N , D } .

% GEND file gend.m Marginal and joint dbn for integer compound demand % Version of 5/21/97% Calculates marginal distribution for compound demand D % and joint distribution for {N,D} in the integer case% Do not forget zero coefficients for missing powers % in the generating functions for N, Ydisp('Do not forget zero coefficients for missing powers') gn = input('Enter gen fn COEFFICIENTS for gN ');gy = input('Enter gen fn COEFFICIENTS for gY '); n = length(gn) - 1; % Highest power in gNm = length(gy) - 1; % Highest power in gY P = zeros(n + 1,n*m + 1); % Base for generating Py = 1; % Initialization P(1,1) = gn(1); % First row of P (P(N=0) in the first position)for i = 1:n % Row by row determination of P y = conv(y,gy); % Successive powers of gyP(i+1,1:i*m+1) = y*gn(i+1); % Successive rows of P endPD = sum(P); % Probability for each possible value of D a = find(gn); % Location of nonzero N probabilitiesb = find(PD); % Location of nonzero D probabilities P = P(a,b); % Removal of zero rows and columnsP = rot90(P); % Orientation as on the plane N = 0:n;N = N(a); % N values with positive probabilites PN = gn(a); % Positive N probabilitiesY = 0:m; % All possible values of Y Y = Y(find(gy)); % Y values with positive probabilitiesPY = gy(find(gy)); % Positive Y proabilities D = 0:n*m; % All possible values of DPD = PD(b); % Positive D probabilities D = D(b); % D values with positive probabilitiesgD = [D; PD]'; % Display combinationdisp('Results are in N, PN, Y, PY, D, PD, P') disp('May use jcalc or jcalcf on N, D, P')disp('To view distribution for D, call for gD')
Got questions? Get instant answers now!

gendf.m function [d,pd] = gendf(gn,gy) is a function version of gend , which allows arbitrary naming of the variables. Calculates the distribution for D , but not the joint distribution for { N , D } .

function [d,pd] = gendf(gn,gy)% GENDF [d,pd] = gendf(gN,gY) Function version of gend.m% Calculates marginal for D in the integer case % Version of 5/21/97% Do not forget zero coefficients for missing powers % in the generating functions for N, Yn = length(gn) - 1; % Highest power in gN m = length(gy) - 1; % Highest power in gYP = zeros(n + 1,n*m + 1); % Base for generating P y = 1; % InitializationP(1,1) = gn(1); % First row of P (P(N=0) in the first position) for i = 1:n % Row by row determination of Py = conv(y,gy); % Successive powers of gy P(i+1,1:i*m+1) = y*gn(i+1); % Successive rows of Pend PD = sum(P); % Probability for each possible value of DD = 0:n*m; % All possible values of D b = find(PD); % Location of nonzero D probabilitiesd = D(b); % D values with positive probabilities pd = PD(b); % Positive D probabilities
Got questions? Get instant answers now!

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Applied probability. OpenStax CNX. Aug 31, 2009 Download for free at http://cnx.org/content/col10708/1.6
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Applied probability' conversation and receive update notifications?

Ask