Generating function of total sales on a given day Given the problem below:
The number of customers that shop at Elmo’s World of Food on a given day is geometrically distributed with parameter $p_1$. The number of items a customer buys at Elmo’s is geometrically distributed with parameter $p_2$. The distribution of the cost of each item is exponentially distributed with parameter $\lambda$. Assume that the amount customers buy and the amount of prices of items are independent. Let $X$ denote the total sales on a given day. Find the generating function of $X$.
In my attempt on solving this I let $N_c$ denote the number of customers that shop on a given fay, $N_i$ denote the number of items a customer buys, and $C$ cost of each item. Then we can write $X = \sum_{k=1}^{N_c} N_i\cdot C$. To find the generating function I used the MGF: $E[e^{tX}]$ and to compute it I conditioned on $N_c$ first and then on $C$. However, my work became very tedious and I'm stuck at simplifying the expression I got. Therefore, I was wondering if there is a different approach I could use in finding the generating function of $X$? This is just a practice problem as I study for my exam.
 A: Answer: The moment generating function for the total sales/profits is
$$ M_X(t) = \textbf{E}[e^{t X}] = \frac{\lambda p_1 p_2}{\lambda p_1 p_2 - t} \qquad \text{where} \qquad(\lambda p_1 p_2 > t).$$
Solution:
To clarify the question a bit: $X$ is the total profit (i.e., total costs of all products purchased) on a given day and since $X$ is effectively a continuous random variable and "generating functions" are typically defined as a way to encode the coefficients of an infinite sequence, I'll assume you want to calculate the moment generating function for $X$.
In order to compute the moment generating function for $X$, we need to compute the probability density function (PDF) for $X$.
By the prompt, we know that the probability that $k$ customers enter the store is $(1-p_1)^{k-1}p_1$. The probability that a single one of those customers purchases $\ell$ items is $(1-p_2)^{\ell-1} p_2$. And the probability density for the cost of a single item is $\lambda e^{-\lambda x}$.
In order to find the PDF for $X$, we need to compute the probabilities for sums of random variables. In particular, the probability that $k$ people purchase a total of $m$ items and that the total cost of these $m$ items is $X$. We note two things

*

*The sum of $k$ geometric random variables with probability of success $p$ is a negative binomial random variable with parameters $k$ and $p$: $\binom{m-1}{k-1} p^k (1-p)^{m-k}$

*The sum of $m$ exponential random variables with rate $\beta$ is a gamma $(m, \beta)$ random variable: $\beta^m x^{m-1} e^{-\beta x}/(m-1)!$
Thus the probability that $m$ items are bought by $k$ customers is $\binom{m-1}{k-1} p_2^k (1-p_2)^{m-k}$, and the PDF for the total costs (i.e., profits) from $m$ items is $\lambda^m X^{m-1} e^{-\lambda X}/(m-1)!$.
The PDF for $k$ customers visiting the store and purchasing a total of $m$ items which have a total cost of $X$ is then
\begin{align}p(k, m, X) &= (1-p_1)^{k-1} p_1 \times\binom{m-1}{k-1} p_2^k (1-p_2)^{m-k}\times\frac{\lambda^m }{(m-1)!}X^{m-1} e^{-\lambda X}\\[.5em]
& = \lambda p_1 p_2 \frac{\left(\lambda p_2(1-p_1) X\right)^{k-1}}{(k-1)!}\frac{\left(\lambda (1-p_2) X\right)^{m-k}}{(m-k)!} e^{-\lambda X}.
\end{align}
To find the PDF for the cost alone, we sum over all possible values of $m$ and $k$. We have
\begin{align}
\rho_{\text{cost}}(X) & = \sum_{k=1}^{\infty}\sum_{m=k}^{\infty}p(k, m, X)\\[.5em]
& = \lambda p_1 p_2 \exp\left( \lambda p_2(1-p_1)X\right) \exp\left( \lambda(1-p_2) X\right) \exp(-\lambda X)\\[.5em] 
& = \lambda p_1 p_2 \exp(-\lambda p_1 p_2 X).
\end{align}
The moment generating function is then
$$ M_X(t) = \textbf{E}[e^{t X}] = \lambda p_1 p_2 \int^{\infty}_{0} dX\, e^{tX - \lambda p_1 p_2 X} = \frac{\lambda p_1 p_2}{\lambda p_1 p_2 - t} \qquad (\lambda p_1 p_2 > t).$$
Random Note: The problem's stated conditions/assumptions seem odd. I would expect the number of people in a store and the number of items each person purchases to follow something more like a poisson distribution and binomial distribution, respectively, rather than geometric distributions. Geometric distributions characterize discrete survival processes which doesn't seem to well model whether people enter a store or how many items they buy.
A: We need to distinguish between two different kinds of probability generating functions: the ordinary power series generating function (OPSGF) and the moment-generating function (MGF).  Suppose $X$ is a discrete random variable that takes on only values in $0,1,2,3,\dots$; then we define the OPSGF of $X$ as
$$f(z) = \sum_{x=0}^{\infty} p(x) z^n$$
where $p(x)$ is the probability density function of $X$.  Equivalently, we may write $f(z) = E[z^x]$.  The MGF of $X$ is defined by $g(t) = E[e^{tx}]$.  The MGF has the advantage that it can be applied to continuous random variables as well as discrete.  There is a simple relation between the two types of generating functions: if $f(z)$ is the OPSGF and $g(z)$ is the MGF, then $g(t) = f(e^t)$.
A useful property of the OPSGF applies to sums of a random number of random variables.  If $X_1, X_2, X_3,...$ are independent random variables all having the OPSGF $f(z)$ and $N$ is an integer random variable with OPSGF $g(z)$, then the OPSGF of $Y= \sum_{i=1}^N X_i$ is $g(f(z))$.  If $f(z)$ is a MGF, then $g(f(z))$ is the MGF of $Y$.
Applying this property to our question, we see that if $f(z)$ is the OPSGF of a geometric random variable with parameter $p_1$, $g(z)$ is the OPSGF of a geometric random variable with parameter $p_2$, and $h(t)$ is the MGF of an exponential random variable with parameter $\lambda$, then the MGF of the total sales is $f(g(h(t)))$.  If you carry out the computation, I think you will find that the total sales have an exponential distribution.
Hint: The OPSGF of a geometric random variable with pdf $(1-p)^{k-1}p$ is
$$f(z) = \frac{pz}{1-(1-p)z}$$
If you are interested in more information about the uses of the OPSGF in probability, one source is An Introduction to Probability Theory and Its Applications, Volume I, Third Edition by William Feller.
