# Conditional expectation given number of outcomes

Let $X_1$, $X_2, \dots, X_n$ be identically distributed random variables with given mean, and let $N$ be a random variable with $N \ge 0$ that is independent of $X_1$, $X_2, \dots, X_n$. If $Y=X_1+X_2+...X_n$; how do we find $\mathrm{E}(Y|N=n)$? With $D$ being the domain of $y$, I know the conditional expectation is defined as

$\mathrm{E}(Y|N=n) = \sum\limits_{y \in D} y \cdot \mathrm{P}(Y=y|N=n) = \sum\limits_{y \in D} y \cdot \dfrac{P(Y=y,N=n)}{P(N=n)}$.

I am not sure how to count/compute $P(Y=y,N=n)$. How can it be computed?

You can use the fact that expectation is linear and compute $E(Y|N=n)$. The fact that $N$ is a random variable does not matter as you are computing the expected value of $Y$ conditional on a specific value of $N$.
Almost all statistics implicitly condition on N. We treat N as a constant that can come out from the expression $\mathbb{E}\left[\frac{1}{N}\sum_{i=1}^{N}{x_i}\right]$, for example. For that to be appropriate, N has to be a fixed value, which we get by conditioning. Without conditioning on N, as you said, we'd need to know the distribution of N, which is kind of strange to think about ("what are my chances of selecting each value of N for my study?").
It is important to assume that the $x_i$ are independent of N, however. This might be violated if, for example, a study has \$100,000 to spend on its subjects and will spend it all no matter how many people are involved. If you are looking at the impact of this spending, then the spending-per-person declines as the number of people increases and N is correlated with your treatment (i.e., spending-per-person).