I am writing code to calculate statistical moments (mean, variance, skewness, kurtosis) for large samples of data and have the requirement of needing to be able to calculate moments for subsections of the sample (in parallel), then combine/merge them to give the moment for the sample as a whole.
For example:
$S = \lbrace 1.0, 1.2, 2.0, 1.7, 3.4, 0.9 \rbrace $
$A = \lbrace 1.0, 1.2, 2.0 \rbrace$ and $B = \lbrace 1.7, 3.4, 0.9 \rbrace$
So $A \cup B = S$
I need to calculate the statistics/moments for $A$ and $B$, then combine them to give the statistics/moments for $S$
Count is simple: $n_S = n_A + n_B$
Mean is not much worse: $\mu_S = (n_A\mu_A + n_B\mu_B) / n_S$
Variance is a little less pretty: $\sigma_S = [n_A\sigma_A + n_B\sigma_B + (\frac{n_An_A}{n_A+n_B})(\mu_A - \mu_B)^2] / n_S$
But now I'm struggling for skewness and, in particular, kurtosis. I have all 'lesser' moments for each of the subsections of the data available and have some idea of the direction I'm heading, but am really struggling to derive the formulae needed.
Has anybody derived these formulae before? Could anyone point me in the right direction? These may be simple/obvious things to any with anyone with a decent amount of statistical knowledge, unfortunately that's something I completely lack...