Given the r.v. $N$ and $K$ such that $N$ is Poisson distributed with parameter $\lambda$. Furthermore let the conditional distribution of $K$ on $N$ be given by
$$ f_{K \mid N} (k \mid n) = \binom{n}{k}p^k(1-p)^{n-k} $$
What is the expectation $E[K \mid N], E[K]$ and $E[N \mid K]$?
I thought for the first one that
$$ E[K \mid N] = \sum_k k \binom{n}{k}p^k(1-p)^{n-k} = np$$
For the second one I've thought of using the formula
$$ f_{K \mid N} (k \mid n) = \frac{f_{K,N}(k,n)}{f_N(n)} $$
Therefore:
$$f_{K,N}(k,n) = f_{K \mid N} (k \mid n)f_N(n) = \frac{e^{-\lambda}\lambda^n}{(n-k)!k!} p^k(1-p)^{n-k} $$
Then usually to get the marginal density, I would have to integrate as follows:
$$ f_K(k) = \int f_{K,N}(k,n) dn = \int \frac{e^{-\lambda}\lambda^n}{(n-k)!k!} p^k(1-p)^{n-k}$$
But is this really the right way or am I doing something wrong?
It is helpful to keep track of the random variables in your computation. Using majuscules for r.v.'s and minuscule for variables, your first computation reads $$E[K \mid N] = \sum_k k \binom{N}{k}p^k(1-p)^{N-k} = Np$$ Thus you can use the law of total expectation to get $$E(K) = E \left[ E (K \mid N) \right] = E [ Np ] = \lambda p$$