How to get the variance of $\sum_{i=1}^{N}x_i$ if $N$ and $x_i$ are random variable? I don't have any idea how to go through this if anyone know how to or know what this problem is called please tell me, this trouble comes up when trying to evaluate the variance of a decision tree (not terminal nodes).
 A: Although you don't specify, I'll assume that you have random variables $X_1,X_2,X_3,...$ that are IID.  Suppose that these random variables have finite mean $\mu$ and finite variance $\sigma^2$, and suppose the random variable $N$ has finite mean $\mu_N$ and finite variance $\sigma_N^2$.
To facilitate the analysis, let $S_n = \sum_{i=1}^n x_i$ denote the sum of the first $n$ variables in the sequence.  This quantity has mean and variance given respectively by:
$$\begin{align}
\mathbb{E}(S_n) 
&= \mathbb{E} \Bigg( \sum_{i=1}^n X_i \Bigg)
= \sum_{i=1}^n \mathbb{E} (X_i)
= \sum_{i=1}^n \mu
= n \mu, \\[12pt]
\mathbb{V}(S_n)
&= \mathbb{V} \Bigg( \sum_{i=1}^n X_i \Bigg) 
= \sum_{i=1}^n \mathbb{V} (X_i)
= \sum_{i=1}^n \sigma^2
= n \sigma^2. \\[12pt]
\end{align}$$
Consequently, using the law of iterated variance you get:
$$\begin{align}
\mathbb{V}(S_N) 
&= \mathbb{E}(\mathbb{V}(S_N | N) ) + \mathbb{V}(\mathbb{E}(S_N | N) ) \\[6pt]
&= \mathbb{E}( N \sigma^2 ) + \mathbb{V}( N \mu ) \\[6pt]
&= \sigma^2 \mathbb{E}(N) + \mu^2 \mathbb{V}(N) \\[6pt]
&= \sigma^2 \mu_N + \mu^2 \sigma_N^2. \\[6pt]
\end{align}$$
So, if you can obtain the mean and variance of $X_i$ and $N$, it is simple to obtain the variance of $S_N$.
