# Characteristic function

Let $\{X_n:n\ge 1\}$ be a sequence of i.i.d. Bernoulli random variables with probability of success $0<p<1$, i.e, $$P\{X_1=1\}=1-P\{X_1=0\}=p.$$ The random variable Y is independent of the sequence $\{X_n:n\ge 1\}$ and has a Poisson distribution with parameter $\lambda>0.$ Find the characteristic function of the random variable $$Z=\sum_{k=1}^{Y+1} X_k.$$

So I know the characteristic function is $\phi_Z(t)=E[e^{itZ}]=E[e^{it\sum_{k=1}^{Y+1} X_k}]$ But I am not sure how to expand the $E[e^{it\sum_{k=1}^{Y+1} X_k}]$ term because whether or not the event $X_k$ for $k>1$ occurs is possion distributed.

My attempt:

The probability of $P(Y=k)= \frac{\lambda^ke^{-\lambda}}{k!}$.

$E[e^{it\sum_{k=1}^{Y+1} X_k}]=\Pi^{\infty}_{k=0}E[P(Y=k)e^{itX_k}]=\Pi^{\infty}_{k=0}P(Y=k)(1-p+pe^{it})=\Pi^{\infty}_{k=0}\frac{\lambda^ke^{-\lambda}}{k!}(1-p+pe^{it})$

Am I on the right track? I am not sure because I have never seen a random variable defined like $Z$ before.

I think you're on the right track, in that the key is to condition on $Y$. By the properties of conditional expectation, $$\mathbb{E}[e^{itZ}]=\sum_{k=0}^{\infty}\mathbb{E}[e^{itZ}|Y=k]\mathbb{P}(Y=k)$$
If $Y=k$ then $Z=X_1+\dots+X_{k+1}$, and since the $X_i$ are i.i.d it follows that $$\mathbb{E}[e^{itZ}|Y=k]=(1-p+pe^{it})^{k+1}$$
Combining this with $\mathbb{P}(Y=k)=\frac{\lambda^k}{k!}e^{-\lambda}$, we get $$\mathbb{E}[e^{itZ}]=\sum_{k=0}^{\infty}(1-p+pe^{it})^{k+1}\frac{\lambda^k}{k!}e^{-\lambda}=(1-p+pe^{it})e^{-\lambda}\sum_{k=0}^{\infty}\frac{[\lambda(1-p+pe^{it})]^k}{k!}$$ $$=(1-p+pe^{it})\exp(\lambda(1-p+pe^{it})-\lambda)=(1-p+pe^{it})\exp(\lambda p(e^{it}-1))$$
Note that if you had instead defined $Z=\sum_{k=1}^YX_k$, then the extra $(1-p+pe^{it})$ term would not be present, and this would be the characteristic function of a Poisson random variable with parameter $\lambda p$.