Averaging a list of variances
Let's assume you have $n$ datasets, $x_k$ is the $k$th dataset. It's length we denote by $l_k$, its elements are $$x_k =\big\{x_k(1), x_k(2), \dots, x_k(l_k)\big\},$$
and its mean and variance are respectively
\begin{align}
\mu_k &amp;= \frac{1}{l_k}\sum_{i=1}^{l_k} x_k(i),\\
\sigma_k^2 &amp;= \frac{1}{l_k}\sum_{i=1}^{l_k} x_k(i)^2 - \mu_k^2.
\end{align}
Then, noting that $l_k\mu_k = \sum_{i=1}^{l_k} x_k(i)$:
\begin{align}
\mu &amp;= \frac{1}{\sum_{k=1}^nl_k}\sum_{k=1}^n\sum_{i=1}^{l_k} x_k(i)\\
\mu &amp;= \frac{1}{\sum_{k=1}^nl_k}\sum_{k=1}^nl_k\mu_k
\end{align}
and in similar fashion
\begin{align}
\sigma^2 &amp;= \frac{1}{\sum_{k=1}^nl_k}\sum_{k=1}^n\sum_{i=1}^{l_k} x_k(i)^2 - \mu^2\\
\sigma^2 &amp;= \frac{1}{\sum_{k=1}^nl_k}\sum_{k=1}^nl_k\left(\sigma^2_k + \mu_k^2\right) - \mu^2
\end{align}
When $l_k = N$ for all $k$ the above simplifies:
\begin{align}
\mu &amp;= \frac{1}{n}\sum_{k=1}^n\mu_k\\
\sigma^2 &amp;= \frac{1}{n}\sum_{k=1}^n\left(\sigma^2_k + \mu_k^2\right) - \mu^2
\end{align}
however when the datasets have different sizes the above does not simplify, and you need to take that into account.