# ­xkcd thread

**URL:** <https://boards.straightdope.com/t/xkcd-thread/854574>\
**Category:** Cafe Society\
**Tags:** comic-strips\
**Created:** [May 28, 2020, 12:57am UTC](https://boards.straightdope.com/t/xkcd-thread/854574 "2020-05-28T00:57:03Z")\
**Posts on this page:** 20\
**Page:** 30

<div class="post-metadata">

**Author:** ![naita](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/naita/32/5862_2.png) [@naita](https://boards.straightdope.com/u/naita)\
**Post date:** [March 11, 2021, 4:22pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/581 "2021-03-11T16:22:00Z")

</div>

> [@dtilque](#):
>
> I suspect that even the math nerds are not going to find this especially funny.

I’m not laughing, but I want to program this now and see what it does to various sequences.

---

<div class="post-metadata">

**Author:** ![SCAdian](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/scadian/32/3292_2.png) [@SCAdian](https://boards.straightdope.com/u/SCAdian)\
**Post date:** [March 11, 2021, 4:31pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/582 "2021-03-11T16:31:45Z")

</div>

> [@dtilque](#):
>
> I suspect that even the math nerds are not going to find this especially funny.

I just forwarded it to my brother-in-law the statistics prof.

---

<div class="post-metadata">

**Author:** ![Pleonast](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pleonast/32/1183_2.png) [@Pleonast](https://boards.straightdope.com/u/Pleonast)\
**Post date:** [March 11, 2021, 4:37pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/583 "2021-03-11T16:37:53Z")

</div>

> [@dtilque](#):
>
> I suspect that even the math nerds are not going to find this especially funny.

Maybe not funny, but definitely fascinating. Something I’ll have to play around with. Can it be proven to always converge?

---

<div class="post-metadata">

**Author:** ![LSLGuy](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/lslguy/32/5813_2.png) [@LSLGuy](https://boards.straightdope.com/u/LSLGuy)\
**Post date:** [March 11, 2021, 5:04pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/584 "2021-03-11T17:04:21Z")

</div>

> [@dtilque](#):
>
> > [@k9bfriender](#):
> >
> > That’s just mean.
> 
> So that’s the mode this is going to be in.

If you two start arguing I’ll have to call a Mod to mediate.

---

<div class="post-metadata">

**Author:** ![naita](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/naita/32/5862_2.png) [@naita](https://boards.straightdope.com/u/naita)\
**Post date:** [March 11, 2021, 5:27pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/585 "2021-03-11T17:27:26Z")

</div>

> [@Pleonast](#):
>
> Maybe not funny, but definitely fascinating. Something I’ll have to play around with. Can it be proven to always converge?

I’d be shocked if it couldn’t. You can ignore the first application of F and just look at the second and following, so you have only three “random” numbers to think about and not “every possible set of numbers”. There probably needs to be some restrictions on signs though, to avoid breaking the geometric mean.

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [March 11, 2021, 5:33pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/586 "2021-03-11T17:33:04Z")

</div>

I played around with some numbers and got Randall’s result. For [1 10 100 1000 10000] as the original set, the convergence is to 308.6637

---

<div class="post-metadata">

**Author:** ![Thing.Fish](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thing.fish/32/9168_2.png) [@Thing.Fish](https://boards.straightdope.com/u/Thing.Fish)\
**Post date:** [March 11, 2021, 5:45pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/587 "2021-03-11T17:45:28Z")

</div>

There’s probably no easy way to explain this joke to someone who has no idea what any of you are talking about, is there?

---

<div class="post-metadata">

**Author:** ![abcdefghij](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@abcdefghij](https://boards.straightdope.com/u/abcdefghij)\
**Post date:** [March 11, 2021, 5:53pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/588 "2021-03-11T17:53:42Z")

</div>

Probably not 😉

---

<div class="post-metadata">

**Author:** ![gdave](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/gdave/32/3683_2.png) [@gdave](https://boards.straightdope.com/u/gdave)\
**Post date:** [March 11, 2021, 5:55pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/589 "2021-03-11T17:55:34Z")

</div>

The “joke”, such as it is, is that arithmetic mean, geometric mean, and median are all different ways to calculate a mathematical average. Randall here is “averaging” the _words_ used to refer to those methods, and creating a mathematical function that’s sort of an average of averages.

---

<div class="post-metadata">

**Author:** ![abcdefghij](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@abcdefghij](https://boards.straightdope.com/u/abcdefghij)\
**Post date:** [March 11, 2021, 6:01pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/590 "2021-03-11T18:01:58Z")

</div>

I’ll try, though.

F() is a function that calculates three different “averages” of a bunch of numbers.

If you give the three averages to F(), then it calculates three averages of those averages.

Now call it again with the averages of averages and get three average-average-averages.

Lather-rinse-repeat until the three numbers you get back keep being the same.

It’s not particularly useful, it’s just kind of interesting… for small values of “interesting”…

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [March 11, 2021, 6:05pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/591 "2021-03-11T18:05:16Z")

</div>

There are many different ways to take a set of numbers and create a single number somehow representative of it. You can take the average (adding all the numbers and dividing by how many numbers there are), you can take the geometric mean (multiply all the numbers and taking the n-th root of the product), and you can find the median (sort all the numbers and take the middle one). For [1 1 2 3 5] the average is 12/5 = 2.4, the geometric mean is the fifth root of 30 (or 1.974) and the median is 2. Randall then takes those three ways of describing [1 1 2 3 5] and takes the average, geometric mean, and median _again_, and _again_ and **again** to see what happens. You eventually get to a point where you have three numbers that are equal - which means that the average, geometric mean, and median of those three numbers don’t change. _Wheee!_

---

<div class="post-metadata">

**Author:** ![Thing.Fish](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/thing.fish/32/9168_2.png) [@Thing.Fish](https://boards.straightdope.com/u/Thing.Fish)\
**Post date:** [March 11, 2021, 6:12pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/592 "2021-03-11T18:12:44Z")

</div>

Thanks for explaining. I know about the three kinds of averages and how to calculate them. I just didn’t know the math terminology well enough to recognize that was what that equation was doing. It’s…still not very funny, is it?

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [March 11, 2021, 6:16pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/593 "2021-03-11T18:16:24Z")

</div>

It’s funny in the way that watching someone get bogged down in details and losing the big picture is funny - you can imagine someone thinking “I want to describe this data set - but is average, median, or geometric mean the best way? I know - I’ll do all three!”

---

<div class="post-metadata">

**Author:** ![k9bfriender](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/k9bfriender/32/3283_2.png) [@k9bfriender](https://boards.straightdope.com/u/k9bfriender)\
**Post date:** [March 11, 2021, 6:16pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/594 "2021-03-11T18:16:53Z")

</div>

xkcd’s tagline

> [@](#):
>
> A webcomic of romance,  
> sarcasm, math, and language.

I don’t see “funny” in there anywhere.

If it gets people to think about something in a way that they have not thought of before, then he has done his job.

---

<div class="post-metadata">

**Author:** ![Pleonast](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pleonast/32/1183_2.png) [@Pleonast](https://boards.straightdope.com/u/Pleonast)\
**Post date:** [March 11, 2021, 8:14pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/595 "2021-03-11T20:14:21Z")

</div>

> [@naita](#):
>
> There probably needs to be some restrictions on signs though, to avoid breaking the geometric mean.

That was the first thing I did!

Gmdn(-1,2,3) ~ 1.443218 + i 0.402679  
Gmdn(1,-2,3) ~ 0.946341 + i 0.983653  
Gmdn(1,2,-3) = 0

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [March 11, 2021, 10:19pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/596 "2021-03-11T22:19:41Z")

</div>

It’s not particularly funny, but it is interesting.

Proof of convergence is easy: All three of those “averages” are guaranteed to return a number greater than the least input and smaller than the greatest input, so the range from least to greatest will always be shrinking. And it’s not too hard to quantify how it shrinks, so you won’t get a situation where you’re asymptotically approaching some nonzero range.

At least, if you’re starting with positive values. Including negatives ends up dealing with complex numbers, as @Pleonast found. How are you taking the median of a set of complex numbers? Like, what’s the median of -2, (1+sqrt(-3)), (1-sqrt(-3))?

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [March 12, 2021, 12:11am UTC](https://boards.straightdope.com/t/xkcd-thread/854574/597 "2021-03-12T00:11:41Z")

</div>

Good question. Some software might use the median real part, and some might output the median absolute value

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [March 12, 2021, 12:19am UTC](https://boards.straightdope.com/t/xkcd-thread/854574/598 "2021-03-12T00:19:22Z")

</div>

It’s worse than that, even, because with either method of ordering complex numbers, you can have two different numbers with the same ordering. Do you pick one of those two as the median (and if so, which one?), or take the arithmetic mean between all of the tied points?

---

<div class="post-metadata">

**Author:** ![Andy\_L](https://avatars.discourse-cdn.com/v4/letter/a/c67d28/32.png) [@Andy\_L](https://boards.straightdope.com/u/Andy_L)\
**Post date:** [March 12, 2021, 1:24pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/599 "2021-03-12T13:24:02Z")

</div>

Looks like MATLAB sorts a vector by absolute value, and takes the center point (or for an even number of points, averages the two centermost points), which means that you can get some surprising results. Median of (i 1 -1) is i, median of (-1, i, -1) is -1 - but median of (-1, i, -1 1) is (i-1)/2

---

<div class="post-metadata">

**Author:** ![Pleonast](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/pleonast/32/1183_2.png) [@Pleonast](https://boards.straightdope.com/u/Pleonast)\
**Post date:** [March 12, 2021, 3:00pm UTC](https://boards.straightdope.com/t/xkcd-thread/854574/600 "2021-03-12T15:00:41Z")

</div>

> [@Chronos](#):
>
> At least, if you’re starting with positive values. Including negatives ends up dealing with complex numbers, as @Pleonast found. How are you taking the median of a set of complex numbers? Like, what’s the median of -2, (1+sqrt(-3)), (1-sqrt(-3))?

I was using the default [numpy](https://numpy.org/doc/stable/reference/) median function which uses a lexical sort. That is, it sorts complex numbers by real component, then imaginary component. For your example, the sorted list would be [-2, 1-sqrt(-3), 1+sqrt(-3)].

While easy to implement, I find that distasteful. For example, the median of [-1, i 100, 1] is i 100. So I implemented by own median function which sorts by magnitude, then real component, then imaginary component.

That changes previous calculations to  
Gmdn(-1,2,3) ~ 1.423165 + i 0.831516  
Gmdn(1,-2,3) ~ 0.927599 + i 0.308025  
Gmdn(1,2,-3) = 0

Not a big difference, actually.

[Previous page](https://boards.straightdope.com/t/xkcd-thread/854574.md?page=29)

[Next page](https://boards.straightdope.com/t/xkcd-thread/854574.md?page=31)
