What is the expectation of a summation where the number of terms itself is a random variable? I have to calculate the following
$$ \mathbb{E} \sum_{i=1}^{N(t)} (t-T_i)
$$
where $N(t)$ is a random variable that follows a Poisson process and $T_i$ is the arrival times.
Can I do the following:
$$ \sum_1^{N(t)} \mathbb{E}(t-T_i) = \sum_1^{N(t)} \mathbb{E}(t) - \sum_1^{N(t)} \mathbb{E}(T_i) = \mathbb{E}(N) \mathbb{E}(t) - \mathbb{E}(N) \mathbb{E}(T_i) \tag{1}
$$
I know that $$ \mathbb{E}\sum_{i=1}^{N(t)}X_i = \mathbb{E}(X).\mathbb{E}[N] \tag{2}
$$
But I'm not sure if I used it the right way in $(1)$. I'd appreciate any help or hint with this!
 A: If the $t$ in $N(t)$ and the $t$ in $(t - T_i)$ are the same, and it is some deterministic variable, then by the law of total expectation
$$\begin{align}
\mathbb E \left[\sum_{i=1}^{N(t)} (t - T_i) \right] 
&= \mathbb E \left[ \mathbb E \left[\left. \sum_{i=1}^{N(t)} (t - T_i) \,\right| N(t) \right]\right] \\
&= \mathbb E \left[ \sum_{i=1}^{N(t)} \mathbb E[t - T_i \mid N(t)]\right] \\
&= \mathbb E \left[ \sum_{i=1}^{N(t)} t - \mathbb E[T_i \mid N(t)] \right] \\
&= \mathbb E \left[ t N(t) - \sum_{i=1}^{N(t)} \mathbb E[T_i \mid N(t)] \right] \\
&= t \;\mathbb E[N(t)] - \mathbb E \left[ \sum_{i=1}^{N(t)} \mathbb E[T_i \mid N(t)] \right].
\end{align}$$
If $T_i$ is independent of $N(t)$ then the summand simplifies to $\mathbb E[T_i]$; then if the $T_i$ are identically distributed with common mean $\mathbb E[T_i] = \mu$, then $$\mathbb E\left[\sum_{i=1}^{N(t)} \mathbb E[T_i]\right] =  \mu \;\mathbb E[N(t)].$$
Note however that if $N(t)$ is given, the arrival times $T_i \mid N(t)$ for a homogeneous process will be uniformly distributed in $[0,t]$; moreover, they will not be identically distributed: rather, it is the interrarival times $T_i - T_{i-1}$ that have this property.  For a inhomogeneous process the calculation becomes dependent on the hazard function $\lambda(t)$ and in general will not have a closed form.
For instance $T_1 \mid N(t)$ will be distributed as the first order statistic of a random sample of size $N(t)$ in a continuous uniform distribution on $[0,t]$; and in general, $T_i \mid N(t)$ will be the $i^{\rm th}$ order statistic.  Hence the expectation will be $$\mathbb E[T_i \mid N(t)] = \frac{it}{N(t) + 1}$$ and the resulting sum will be $t N(t)/2$, from which we would conclude the desired expectation is simply $$(t - t/2)\mathbb E[N(t)] = t \mathbb E[N(t)]/2.$$  Then if $\mathbb E[N(t)] = \lambda t$ we get $\lambda t^2/2$ as the result.
