Suppose that we have $X_1, X_2, \ldots$ is a sequence of i.i.d random variables with $E(X_i)<+\infty$ and $N$ is a random variable taking values in $\{1,2,\ldots\}$, $N$ is independent with $X_1, X_2, \ldots$.
I know that $$E\left(\sum_{i=1}^N X_i \right) = E(N)E(X_1)$$
If I divide the sum by $N$, $$M = \frac 1N \sum_{i=1}^N X_i $$ I have sample mean of $X_1, X_2,\ldots, X_N$ but $N$ is random. In this case, what is the distribution of $M$ and how to calculate $E(M)$ and $Var(M)$. Thanks.
The law of total expectation gives $${\rm E}[M] = {\rm E}[{\rm E}[M \mid N]] = {\rm E}[(N {\rm E}[X_1])/N] = {\rm E}[X_1],$$ as you might guess. The law of total variance gives $$\begin{align*} {\rm Var}[M] &= {\rm Var}[{\rm E}[M \mid N]] + {\rm E}[{\rm Var}[M \mid N]] \\ &= {\rm Var}[{\rm E}[X_1]] + {\rm E}\bigl[\tfrac{1}{N^2} \cdot N {\rm Var}[X_1]\bigr] \\ &= 0 + {\rm Var}[X_1]{\rm E}[1/N] \\ &= {\rm Var}[X_1]{\rm E}[1/N]. \end{align*}$$