Calculate the sufficient statistics (average & second moment) of two sets.

For more details, see the parallel algorithm of Chan et al. at:

Takes in the sufficient statistics for sets A and B and calculates the variance and sufficient statistics for the union of A and B.

If e.g. B is a single observation x_b, use n_b=1, avg_b = x_b, and m2_b = 0.

To get avg_a and m2_a from a tensor x of shape [n_a, ...], use:

n_a = tf.shape(x)[0]
avg_a, var_a = tf.nn.moments(x, axes=[0])
m2_a = var_a * n_a

n_a Number of elements in A.
avg_a The sample average of A.
m2_a The sample second moment of A.
n_b Number of elements in B.
avg_b The sample average of B.
m2_b The sample second moment of B.

A tuple (n_ab, avg_ab, m2_ab) such that var_ab, the variance of A|B, may be calculated via var_ab = m2_ab / n_ab, and the sample variance may be calculated as sample_var_ab = m2_ab / (n_ab - 1).