# Variance of combined samples?

**URL:** <https://boards.straightdope.com/t/variance-of-combined-samples/290573>\
**Category:** Factual Questions\
**Created:** [February 17, 2005, 6:14pm UTC](https://boards.straightdope.com/t/variance-of-combined-samples/290573 "2005-02-17T18:14:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [February 17, 2005, 6:14pm UTC](https://boards.straightdope.com/t/variance-of-combined-samples/290573/1 "2005-02-17T18:14:59Z")

</div>

Say you’ve got two sample groups of single real-valued measurements. Call them S and T, with |S| = m and |T| = n. Call the combined group of measurements X.

Since the boards don’t offer great notation, I’ll use ave() to denote the sample mean, and var() to denote the (unbiased) sample variance. It’s easy to derive that ave(X) = m/(m + n) \* ave(S) + n/(m + n) \* ave(T). What is var(X) in terms of var(S) and var(T)?

If I was at home, I could do this–I know all the formulas but the algebra is involved.

---

<div class="post-metadata">

**Author:** ![Punoqllads](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Punoqllads](https://boards.straightdope.com/u/Punoqllads)\
**Post date:** [February 17, 2005, 7:43pm UTC](https://boards.straightdope.com/t/variance-of-combined-samples/290573/2 "2005-02-17T19:43:19Z")

</div>

Well, var(S) = avg(S[sup]2[/sup]) - avg(S)[sup]2[/sup], so avg(S[sup]2[/sup]) = var(S) - avg(S)[sup]2[/sup]  
so var(X) = m/(m+n) \* (var(S) - avg(S)[sup]2[/sup]) + n/(m+n) \* (var(T) - avg(T)[sup]2[/sup]) - avg(X)[sup]2[/sup]

---

<div class="post-metadata">

**Author:** ![Punoqllads](https://avatars.discourse-cdn.com/v4/letter/p/d2c977/32.png) [@Punoqllads](https://boards.straightdope.com/u/Punoqllads)\
**Post date:** [February 17, 2005, 7:46pm UTC](https://boards.straightdope.com/t/variance-of-combined-samples/290573/3 "2005-02-17T19:46:14Z")

</div>

> [@Punoqllads](#):
>
> Well, var(S) = avg(S[sup]2[/sup]) - avg(S)[sup]2[/sup], so avg(S[sup]2[/sup]) = var(S) - avg(S)[sup]2[/sup]  
> so var(X) = m/(m+n) \* (var(S) - avg(S)[sup]2[/sup]) + n/(m+n) \* (var(T) - avg(T)[sup]2[/sup]) - avg(X)[sup]2[/sup]

D’oh.

avg(S[sup]2[/sup]) = var(S) **+** avg(S)[sup]2[/sup]

so make that

var(X) = m/(m+n) \* (var(S) + avg(S)[sup]2[/sup]) + n/(m+n) \* (var(T) + avg(T)[sup]2[/sup]) - avg(X)[sup]2[/sup]

math is hard

---

<div class="post-metadata">

**Author:** ![ultrafilter](https://avatars.discourse-cdn.com/v4/letter/u/3d9bf3/32.png) [@ultrafilter](https://boards.straightdope.com/u/ultrafilter)\
**Post date:** [February 17, 2005, 8:09pm UTC](https://boards.straightdope.com/t/variance-of-combined-samples/290573/4 "2005-02-17T20:09:30Z")

</div>

I hadn’t considered that approach, but it looks like it’ll work nicely, and it generalizes to an arbitrary number of samples as well. Thanks.
