Binomial and exponential distribution If I am given $N$ is from a binomial distribution with the parameter $n,p$ and also $X$ is from exponential distribution with the parameter $\lambda$.
Assume that $S_N=X_1+X_2+...+X_N$.
How can I find the distribution of $S$?
 A: Since $S_N$ is the sum of $N$ many i.i.d. $\exp(\lambda)$ random variables, therefore $S_N \sim \Gamma(N , \lambda)$ .
Now, $N \sim \text{Bin}(n , p)$. Therefore, $S_N~|~N = k~ \sim \Gamma(k , \lambda)$ . Thus, $S_N$ is a mixture of a Gamma r.v., and a Binomial r.v., and it's PDF will be : \begin{align*} f_{S_N} (x) &= \sum_{k = 0}^n f_{\Gamma}(k , \lambda) \cdot f_N (k)\\
&= e^{-\lambda x}\sum_{k = 0}^n \frac{\lambda^k x^{k-1}}{(k-1)!} \cdot \binom{n}{k}p^k (1 - p)^{n-k}
\end{align*}
I don't know if this sum can be simplified or not. Whatever be the sum, this is the density of $S_N$.
A: Since $X_1,...,X_N \sim \text{IID Exp}(\lambda)$ you have $S_N | N \sim \text{Ga}(n, \lambda)$.  Applying the law of total probability conditional on $N=k$ gives you the probability density function:
$$\begin{align}
f_{S_N}(s)
&= \sum_{k=0}^n \text{Ga}(s| k, \lambda) \cdot \text{Bin}(k|n,p) \\[6pt]
&= \mathbb{I}(s=0) \cdot \text{Bin}(0|n,p) + \sum_{k=1}^n \text{Ga}(s| k, \lambda) \cdot \text{Bin}(k|n,p) \\[6pt]
&= \mathbb{I}(s=0) \cdot (1-p)^n + \exp(-\lambda s) \sum_{k=1}^n \frac{\lambda^k  s^{k-1}}{(k-1)!} \cdot \frac{n!}{k!(n-k)!} \cdot p^k (1-p)^{n-k} \\[6pt]
&= \mathbb{I}(s=0) \cdot (1-p)^n + \frac{(1-p)^n}{s} \cdot \exp(-\lambda s) \sum_{k=1}^n \frac{(n)_k}{k} \cdot \bigg( \frac{\lambda s p}{1-p} \bigg)^k \\[6pt]
&= \mathbb{I}(s=0) \cdot (1-p)^n + \frac{(1-p)^n}{s} \cdot \exp(-\lambda s) \cdot G \Big( \frac{\lambda s p}{1-p} \Big), \\[6pt]
\end{align}$$
where $(n)_k = \prod_{i=1}^k (n-i+1)$ denotes the falling factorial, and
where we have used the ordinary generating function for the series $0, (n)_1, (n)_2/2, (n)_3/3, ...$, which is given by:
$$G(t) \equiv \sum_{k=1}^n \frac{(n)_k}{k} \cdot t^k.$$
This is a mixture distribution with a discrete part at $s=0$ and continuous part over the support $s>0$.  I am not aware of any further simplification for the ordinary generating function $G$, so it would seem that this is the most simplified form for the density.
A: Building on the answer by @Kolmogorov. First, this mixture distribution does have an atom at zero, since if $N=0$ (with probability $(1-p)^n$), then $S_N=0$, as an empty sum. In the other case, conditional on $N\ge 1$, $S_N$ has a continuous distribution. The sum, given by @Kolmogorov, seems difficult, but maple is able to "simplify" it, and finds a solution with Laguerre polynomials:
sum( (lambda^k*x^(k-1) * exp(-lambda*x) / (k-1)! )*binomial(n,k)*p^k*(1-p)^(n-k), k=1..n ) assuming lambda> 0,n,posint,x,real,p>0,p<1;

with result
$$
 \lambda\,{{\rm e}^{-\lambda\,x}}p \left( 1-p \right) ^{n-1} \left( -{
\it LaguerreL} \left( n,{\frac {\lambda\,xp}{-1+p}} \right) +{\it 
LaguerreL} \left( n,1,{\frac {\lambda\,xp}{-1+p}} \right)  \right) 
$$
See NIST Digital Library of Mathematical Functions. For instance, in R, there is an implementation in package mpoly on CRAN, and probably otherplace.
