Editing Talk:2435: Geothmetic Meandian

Jump to: navigation, search
Ambox notice.png Please sign your posts with ~~~~

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 40: Line 40:
  
 
I do not agree with the statement that "The title text may also be a sly reference to an actual mathematical theorem, namely that if one performs this procedure only using the arithmetic mean and the harmonic mean, the result will converge to the geometric mean." Could one produce a reference to this result? A simple computer experiment does not show this "theorem" to be true, i.e. for the procedure to return the geometric mean of the original entry. [[User:Pointfivegully|Pointfivegully]] ([[User talk:Pointfivegully|talk]]) 15:04, 12 March 2021 (UTC)
 
I do not agree with the statement that "The title text may also be a sly reference to an actual mathematical theorem, namely that if one performs this procedure only using the arithmetic mean and the harmonic mean, the result will converge to the geometric mean." Could one produce a reference to this result? A simple computer experiment does not show this "theorem" to be true, i.e. for the procedure to return the geometric mean of the original entry. [[User:Pointfivegully|Pointfivegully]] ([[User talk:Pointfivegully|talk]]) 15:04, 12 March 2021 (UTC)
 
= Here is a reference https://math.stackexchange.com/questions/1734978/computing-square-roots-with-arithmetic-harmonic-mean. You must have made a mistake in your computer experiment. As an example, see the details I posted about Cueball and Megan exchanging dollars and euros. This is actually a handy way to compute square roots by hand.
 
  
 
== Proof of convergence ==
 
== Proof of convergence ==
Line 156: Line 154:
  
 
:For something as simple as this, I always find it cheating to use a package to abstract away the few actually necessary calculations. You might as well use a DWIM module and do 'result = DWIM(input)' as the sole command. But that's me for you. I'd write my own direct-to-memory screen RAM accesses, if silly things like OS HALs and GPU acceleration (once you find a way to message them as directly as possible) hadn't long since made that pretty much moot, if not actually verboten... [[Special:Contributions/141.101.99.109|141.101.99.109]] 17:53, 11 March 2021 (UTC)
 
:For something as simple as this, I always find it cheating to use a package to abstract away the few actually necessary calculations. You might as well use a DWIM module and do 'result = DWIM(input)' as the sole command. But that's me for you. I'd write my own direct-to-memory screen RAM accesses, if silly things like OS HALs and GPU acceleration (once you find a way to message them as directly as possible) hadn't long since made that pretty much moot, if not actually verboten... [[Special:Contributions/141.101.99.109|141.101.99.109]] 17:53, 11 March 2021 (UTC)
 
 
 
 
 
 
 
I'd like to add my own implementation:
 
 
from math import *
 
def getMeans(n=list):
 
    n.sort()
 
    mean=sum(n)/len(n)
 
    if len(n)%2==1:
 
        median=n[len(n)//2]
 
    else:
 
        median=(n[1+floor(len(n)/2)]-n[floor(len(n)/2)])/2
 
    prod=1
 
    for i in n:
 
        prod*=i
 
    gmean=prod**(1/len(n))
 
    return [mean,median,gmean]
 
def gmdn(tol,n=list):
 
    mList=n
 
    mList=getMeans(mList)
 
    while not (isclose(mList[0],mList[1],rel_tol=tol) and isclose(mList[1],mList[2],rel_tol=tol) and
 
isclose(mList[0],mList[2],rel_tol=tol) ) :
 
        mList = getMeans(mList)
 
    return (mList[0]+mList[1]+mList[2])/3
 
print(gmdn(1e-15,[1,1,2,3,5]))
 
 
which gives me 2.089057949736859
 
  
 
== Sloppy notation? ==
 
== Sloppy notation? ==
Line 193: Line 159:
 
As a mathematician, I immediately noticed a couple of annoying niggles. Firstly, it is only implied, but never clearly stated, that the input list is ordered - which means the median is wrong unless ordered. Now F outputs an ordered triple of real numbers, and in calculating G, this is fed in to F again directly. This will frequently give inputs that are not in order, and in subsequent iterations the "median" will always be the middle number - i.e. the geometric mean - regardless of the actual median. Secondly, Randall's final line gives the output of G as a single number, but as it is just the result of a repeated application of F, the output of G should be an ordered triple. I'm sure Randall is aware of both, and chose to cut out the implied ordering of the inputs and choosing one of the three values as the output of G as they aren't necessary for the joke, but maybe we should note something about this in the explanation.[[Special:Contributions/141.101.99.109|141.101.99.109]] 13:07, 11 March 2021 (UTC)
 
As a mathematician, I immediately noticed a couple of annoying niggles. Firstly, it is only implied, but never clearly stated, that the input list is ordered - which means the median is wrong unless ordered. Now F outputs an ordered triple of real numbers, and in calculating G, this is fed in to F again directly. This will frequently give inputs that are not in order, and in subsequent iterations the "median" will always be the middle number - i.e. the geometric mean - regardless of the actual median. Secondly, Randall's final line gives the output of G as a single number, but as it is just the result of a repeated application of F, the output of G should be an ordered triple. I'm sure Randall is aware of both, and chose to cut out the implied ordering of the inputs and choosing one of the three values as the output of G as they aren't necessary for the joke, but maybe we should note something about this in the explanation.[[Special:Contributions/141.101.99.109|141.101.99.109]] 13:07, 11 March 2021 (UTC)
 
:First, I've never seen a definition of median which doesn't account for ordering itself, although I am a little annoyed at his definition for a different reason— that it doesn't account for even-length lists. Second, what I got from the comic initially is that G<sub>MDN</sub> is supposed to be a single number, specifically that value for which all three of its elements would become equal if implemented infinitely many times (and it ''will'' converge, because if the three elements are all the same it already has converged, and if at least two are different, both means will necessarily become greater than the least value and smaller than the greatest value due to the definition of 'mean'). Another annoyance I noted is that G<sub>MDN</sub> is real iff there are an even number of negative numbers and/or the length of the initial list is odd, but I suppose that can't be helped. Ooh, complex meandianing! [[User:BlackHat|BlackHat]] ([[User talk:BlackHat|talk]]) 15:15, 11 March 2021 (UTC)
 
:First, I've never seen a definition of median which doesn't account for ordering itself, although I am a little annoyed at his definition for a different reason— that it doesn't account for even-length lists. Second, what I got from the comic initially is that G<sub>MDN</sub> is supposed to be a single number, specifically that value for which all three of its elements would become equal if implemented infinitely many times (and it ''will'' converge, because if the three elements are all the same it already has converged, and if at least two are different, both means will necessarily become greater than the least value and smaller than the greatest value due to the definition of 'mean'). Another annoyance I noted is that G<sub>MDN</sub> is real iff there are an even number of negative numbers and/or the length of the initial list is odd, but I suppose that can't be helped. Ooh, complex meandianing! [[User:BlackHat|BlackHat]] ([[User talk:BlackHat|talk]]) 15:15, 11 March 2021 (UTC)
::I guess it depends on whether we take x_{(n+1)/2} literally or not. If taken literally, the elements need to be sorted, and even-length lists don't work. If we assume the "median" is the literal part, and the notation is just a simplified sketch, then both are okay (median of even list is average of the two "middle" elements). [[Special:Contributions/172.68.143.160|172.68.143.160]] 22:00, 12 March 2021 (UTC)
 
  
 
== Is the arithmetic-geometric mean connected to geometry? ==
 
== Is the arithmetic-geometric mean connected to geometry? ==
Line 204: Line 169:
  
 
R = GMDN(a,b,c)
 
R = GMDN(a,b,c)
 
: Here is a geometric interpretation of the inequality between them: {{w|Inequality_of_arithmetic_and_geometric_means#Geometric_interpretation}}. [[User:Danloeb|DanLoeb]] ([[User talk:Danloeb|talk]]) 19:31, 14 March 2021 (UTC) D--[[User:Danloeb|DanLoeb]] ([[User talk:Danloeb|talk]]) 19:31, 14 March 2021 (UTC)
 
  
 
=== The RandallMunroe Set ===
 
=== The RandallMunroe Set ===
Line 282: Line 245:
 
     result = y(2);
 
     result = y(2);
 
     end
 
     end
 
My python program:
 
from math import *
 
def getMeans(n=list):
 
    n.sort()
 
    mean=sum(n)/len(n)
 
    if len(n)%2==1:
 
        median=n[len(n)//2]
 
    else:
 
        median=(n[1+floor(len(n)/2)]-n[floor(len(n)/2)])/2
 
    prod=1
 
    for i in n:
 
        prod*=i
 
    gmean=prod**(1/len(n))
 
    return [mean,median,gmean]
 
def gmdn(tol,n=list):
 
    mList=n
 
    mList=getMeans(mList)
 
    while not (isclose(mList[0],mList[1],rel_tol=tol) and isclose(mList[1],mList[2],rel_tol=tol) and
 
isclose(mList[0],mList[2],rel_tol=tol) ) :
 
        mList = getMeans(mList)
 
    return mList[0]
 
print(gmdn(1e-15,[1,1,2,3,5]))
 
 
It gave me 2.0890579497368584
 
  
 
== Proof - Possibly by Induction ==
 
== Proof - Possibly by Induction ==
Line 335: Line 273:
 
:How can this be formulated as a PDE when F isn't even differentiable?
 
:How can this be formulated as a PDE when F isn't even differentiable?
 
:Besides, R(Fn+1) < R(Fn) does not imply limit R(Fn) = 0 (Think R(n) := 1+1/n). -- [[User:Xorg|Xorg]] ([[User talk:Xorg|talk]]) 02:50, 12 March 2021 (UTC)
 
:Besides, R(Fn+1) < R(Fn) does not imply limit R(Fn) = 0 (Think R(n) := 1+1/n). -- [[User:Xorg|Xorg]] ([[User talk:Xorg|talk]]) 02:50, 12 March 2021 (UTC)
Agreed. F is not differentiable due to median. For arbitrary R(n) such as R(n)=1+1/n then limit R(Fn) != 0, however I do not define R(n) arbitrarily but define it as R(n)=max(An,Bn,Cn)-min(An,Bn,Cn) [[User:Ramakarl|Ramakarl]] <br>
+
Agreed. F is not differentiable due to median. For arbitrary R(n) such as R(n)=1+1/n then limit R(Fn) != 0, however I do not define R(n) arbitrarily but define it as R(n)=max(An,Bn,Cn)-min(An,Bn,Cn) --Ramakarl<br>
  
 
[[User:snark]]
 
[[User:snark]]
Line 344: Line 282:
 
and show that is is less than the first distance.
 
and show that is is less than the first distance.
  
Agreed. I've removed reference to PDE or Heat equation except for the indirect similarity. The new suggestion for proof, which is incomplete, is inductive based on the observed alternation of the min/max between the geomean and arithmean. I believe it can be shown that for some N, there exists F(N)=k, where k=min(N)=max(N)=arithmean(N)=geomean(N)=median(N) within some epsilon, and k is the fixed point. This is because the min(n+1), median(n+1) and max(n+1) alternate between arithmean(n) and geomean(n), which are strictly inside the open interval ( min(n), max(n) ). [[User:Ramakarl|Ramakarl]]
+
Agreed. I've removed reference to PDE or Heat equation except for the indirect similarity. The new suggestion for proof, which is incomplete, is inductive based on the observed alternation of the min/max between the geomean and arithmean. I believe it can be shown that for some N, there exists F(N)=k, where k=min(N)=max(N)=arithmean(N)=geomean(N)=median(N) within some epsilon, and k is the fixed point. This is because the min(n+1), median(n+1) and max(n+1) alternate between arithmean(n) and geomean(n), which are strictly inside the open interval ( min(n), max(n) ). --Ramakarl
 
 
I believe we can produce a simpler, rigorous proof. Assuming a set of three is given, we can show that after every 2 iterations, the range is reduced by at least 1/3 of its original value, and therefore it converges exponentially to 0. We use the fact that each iteration, none of the three values will lie outside the range of the previous iteration. In addition, it can be shown that the arithmean lies at least 1/3 of the previous range away from the highest and lowest values of the previous iteration.
 
 
 
If the arithmean is the highest or lowest value on the first iteration, then the range will therefore already be small enough (and won't get bigger in the second iteration.) Otherwise, the only remaining option is that it is the middle (median) value. So on the second iteration, both the median and the arithmean are within the reduced 1/3 range, and at least one of them must be the highest or lowest value. The range will always be the required size.
 
 
 
Edit: Note that this proof holds only assuming the values are nonnegative. Some sets of values including negative ones, such as gmdn(-4,-4,1), do not converge.
 
[[Special:Contributions/141.101.98.16|141.101.98.16]]
 
  
 
== Why is this funny? ==
 
== Why is this funny? ==
Line 357: Line 288:
 
I am impressed with how much people know. After all that explanation, can anyone tell me if there is anything comical about this comic?
 
I am impressed with how much people know. After all that explanation, can anyone tell me if there is anything comical about this comic?
 
Aside from the fact that Randal is combining formulas that don't usually get combined, is there anything here that strikes anyone as funny? The previous one about people asking absurd questions about what they could do after they are vaccinated had me laughing out loud. Can anyone tell me that they laughed at this comic and what was funny? Thanks. [[User:Rtanenbaum|Rtanenbaum]] ([[User talk:Rtanenbaum|talk]]) 01:56, 12 March 2021 (UTC)
 
Aside from the fact that Randal is combining formulas that don't usually get combined, is there anything here that strikes anyone as funny? The previous one about people asking absurd questions about what they could do after they are vaccinated had me laughing out loud. Can anyone tell me that they laughed at this comic and what was funny? Thanks. [[User:Rtanenbaum|Rtanenbaum]] ([[User talk:Rtanenbaum|talk]]) 01:56, 12 March 2021 (UTC)
:YMMV, but I found it funny because I just spent the last fortnight teaching how to find mean (and median, and quartiles for that matter) to 15/16yrolds. And they found that hard enough. I did not inform them of Geometric mean. I guess it's funny to me because it's such a long reach. [[User:Thisfox|Thisfox]] ([[User talk:Thisfox|talk]]) 02:48, 12 March 2021 (UTC)
+
:YMMV, but I found it funny because I just spent the last fortnight teaching how to find mean (and median, and quartiles for that matter) to 15/16yrolds. And they found that hard enough. I did not inform them of Geometric mean. I guess it's funny because it's such a long reach. [[User:Thisfox|Thisfox]] ([[User talk:Thisfox|talk]]) 02:48, 12 March 2021 (UTC)
 
::No, the joke is quite clearly explained in the text below the formula: "Pro Tip: If in doubt just mash them together". [[User:Elektrizikekswerk|Elektrizikekswerk]] ([[User talk:Elektrizikekswerk|talk]]) 07:53, 12 March 2021 (UTC)
 
::No, the joke is quite clearly explained in the text below the formula: "Pro Tip: If in doubt just mash them together". [[User:Elektrizikekswerk|Elektrizikekswerk]] ([[User talk:Elektrizikekswerk|talk]]) 07:53, 12 March 2021 (UTC)
 
::As I'm currently supposed to be working someone else should please add this with a proper formulation. I just re-added the incomplete tag. [[User:Elektrizikekswerk|Elektrizikekswerk]] ([[User talk:Elektrizikekswerk|talk]]) 08:00, 12 March 2021 (UTC)
 
::As I'm currently supposed to be working someone else should please add this with a proper formulation. I just re-added the incomplete tag. [[User:Elektrizikekswerk|Elektrizikekswerk]] ([[User talk:Elektrizikekswerk|talk]]) 08:00, 12 March 2021 (UTC)
Line 363: Line 294:
 
::Apparantly someone deleted the tag again without giving a further explanation... I will undo this change. [[User:Elektrizikekswerk|Elektrizikekswerk]] ([[User talk:Elektrizikekswerk|talk]]) 09:58, 12 March 2021 (UTC)
 
::Apparantly someone deleted the tag again without giving a further explanation... I will undo this change. [[User:Elektrizikekswerk|Elektrizikekswerk]] ([[User talk:Elektrizikekswerk|talk]]) 09:58, 12 March 2021 (UTC)
 
:::'Twas not I, but note that this is 'explainxkcd' not 'explainwhyxkcdisfunny'. I think we both recognise that a cornucopia of details have been explained. It is even funnier to see someone insisting we continue to dissect the frog, but I'm not sure I need to fully explain that. ;) [[Special:Contributions/162.158.159.108|162.158.159.108]] 15:16, 12 March 2021 (UTC)
 
:::'Twas not I, but note that this is 'explainxkcd' not 'explainwhyxkcdisfunny'. I think we both recognise that a cornucopia of details have been explained. It is even funnier to see someone insisting we continue to dissect the frog, but I'm not sure I need to fully explain that. ;) [[Special:Contributions/162.158.159.108|162.158.159.108]] 15:16, 12 March 2021 (UTC)
:Yes, here's a bit more on that.. I agree with [[User:Elektrizikekswerk|Elektrizikekswerk]] the joke is explained. The stat tip: "If you aren't sure whether to use the mean, median or geometric mean, just calculate all three, then repeat until it converges." is funny because there are many situations in the physical sciences where the arthmean, geometric mean and median for some data are different values. It is perhaps common that scientists not well versed in statistics are unsure which to use. The funny bit is imagining this less-statistically-versed-scientist throwing up their hands and just accepting the fixed constant given by iterating GMDN as the 'answer' irrelevant of any physical meaning. Also the name "geothmetic meandian" is funny because the word meandian is similar to both median, which it uses, and to ''meander'' which is indicated by the alternate assignment of the median on each iteration -- informally, this function meanders. [[User:Ramakarl|Ramakarl]]
+
:Yes, here's a bit more on that.. I agree with [[User:Elektrizikekswerk|Elektrizikekswerk]] the joke is explained. The stat tip: "If you aren't sure whether to use the mean, median or geometric mean, just calculate all three, then repeat until it converges." is funny because there are many situations in the physical sciences where the arthmean, geometric mean and median of some data give different values. It is perhaps common that scientists not well versed in statistics are unsure which to use. The funny bit is imagining this less-statistically-versed-scientist throwing up their hands and just accepting the fixed constant given by GMDN as the 'answer' irrelevant of any physical meaning. [[User:Ramakarl|Ramakarl]]
:Thanks to all who shared the absurdity so I could also enjoy the joke, and the joke is on me for needing to have a joke "explained". Now where is the button for me to give credit to the best answer? I want to be sure you get points toward your next-level badge. ;-) [[User:Rtanenbaum|Rtanenbaum]] ([[User talk:Rtanenbaum|talk]]) 16:23, 13 March 2021 (UTC)
 
:This is actually one of my favorite xkcd comics. Even before seeing this comic, one thing I would always do was take the AM(AM,GM) instead of using either average on it's own. [[User:nullcline|nullcline]] ([[User talk:nullcline|talk]]) 17:33, 20 July 2021 (UTC)
 
 
 
== PyPi-package ==
 
I made a PyPi-package, if anyone (for some God-forsaken reason) want to use this without implementing it (ya lazy gits): https://pypi.org/project/GMDN/ [[User:BollaBerg|BollaBerg]] ([[User talk:BollaBerg|talk]]) 15:03, 15 March 2021 (UTC)
 
 
 
== Proof - extension to negative values ==
 
 
 
As others have proven, the geothmetic meandian converges for <code>a,b,c > 0</code>.
 
 
 
Case <code>a==0, b,c>=0</code> (and permutations):
 
: then the geometric mean will always be 0. All derivations for <code>a,b,c > 0</code> still apply, thus the set always converges to 0.
 
 
 
Case <code>a,b,c <= 0</code>:
 
: <code>arithmean(a,b,c) == -arithmean(-a,-b,-c)</code>; the same holds for the median and the geometric mean. Thus convergence is given, with the absolute value of the result the same as for positive inputs.
 
 
 
Case <code>a<0, b,c>0</code>, Case <code>a,b<0, c>0</code>
 
: the geometric mean is negative iff 1 or 3 inputs are negative.
 
: the median is negative iff 2 or 3 inputs are negative.
 
: thus, any mixed sign input will yield a mixed sign output.
 
: thus, '''if''' the geothmetic meandian converges for mixed-sign inputs, the limit has to be +-0.
 
: unfortunately, the proof by 141.101.98.16 does not hold here unmodified: it relies on the next set always being within the range of the previous set. This is not true for the geometric mean with mixed-sign inputs. E.g. <code>geommean(-1,2,4)=-4</code>.
 
: However, what does hold is that geometric mean is always within the extended range of <code>+- max(abs(inputs))</code>.
 
: this is not yet sufficient proof.
 
[[User:Xlf|Xlf]] ([[User talk:Xlf|talk]]) 18:05, 15 March 2021 (UTC)
 
 
 
Given <code>M<sub>n</sub> := max(abs(inputs<sub>n</sub>))</code> and <code>min<sub>n</sub> < 0 < max<sub>n</sub></code>, we still have <code>abs(AM<sub>n</sub>) ≤ M<sub>n</sub>*2/3</code> (by dropping a summand with different sign from AM<sub>n</sub>), <code>abs(AM<sub>n+1</sub>) ≤ M<sub>n+1</sub>*2/3 ≤ M<sub>n</sub>*2/3</code> and <code>abs(mid<sub>n+1</sub>) ≤ abs(AM<sub>n</sub>) ≤ M<sub>n</sub>*2/3</code>, because AM<sub>n</sub> shares a sign with one of the others. <code>abs(GM<sub>n+1</sub>) = abs(GM<sub>n</sub>*mid<sub>n</sub>*AM<sub>n</sub>)<sup>(1/3)</sup> ≤ M<sub>n</sub>*(1*1*2/3)<sup>(1/3)</sup> ≤ M<sub>n</sub>*(2/3)<sup>(1/3)</sup></code>.
 
Consequently <code>M<sub>n+2</sub>/M<sub>n</sub> ≤ (2/3)<sup>(1/3)</sup></code>, which shows convergence to 0. □ -- [[User:Xorg|Xorg]] ([[User talk:Xorg|talk]]) 16:43, 31 March 2021 (UTC)
 
 
 
Edit: Deleted comment. Sorry for the accidental spam. [[User talk:Quillathe Siannodel|<sup>{)|(}</sup>]][[User:Quillathe_Siannodel|Quill]][[User talk:Quillathe Siannodel|<sub>{)|(}</sub>]] 14:54, 25 March 2021 (UTC)
 
:The joke is still not explained, as far as I can tell. Maybe it's too obvious but since people asked (see three sections above in the comments) I think the explanation of the actual joke shoudl be added. As I too find it quite obvious what the joke is I find it hard to really explain it which is the reason why I didn't. Besides of that, the incomplete tag actually says why it's incomplete (in this case). AND there is already a comment section (again, three sections above) about this problem. [[User:Elektrizikekswerk|Elektrizikekswerk]] ([[User talk:Elektrizikekswerk|talk]]) 07:41, 26 March 2021 (UTC)
 
::Sorry. That wasn't a thing when I added this section.
 
 
 
can someone help me with my python code of this? i dont get why this isnt working! https://replit.com/@Bumpf/geothmetic for my code. if you want i can paste my code here. i also commented in the code the error and why i dont understand it. thank you in advance! (also the geometric formula thing in the table on the page is showing a big red error. Maybe fix that?) [[Special:Contributions/172.70.38.56|172.70.38.56]] 13:35, 26 March 2021 (UTC)Bumpf
 
 
 
Since it uses F(F(F...)) someone should write a Hascal version that actually uses the fixedpoint function. [[Special:Contributions/172.69.35.175|172.69.35.175]] 22:56, 30 March 2021 (UTC)
 
 
 
Short proof that the thing converges. Basically there are three cases, one is that the median is larger than both one is that it is smaller than both and one is that it is in between. If it is in between, both he max must decrease and the min must increase. If it is greater, then the minimum must increase. If it is less, the maximum must decrease. In all three cases max(F(n+1))-min(F(n+1))<max(F(n))-min(F(n)) so by monotonic convergence theorem it must converge.
 
[[Special:Contributions/172.70.206.163|172.70.206.163]] 02:40, 1 April 2022 (UTC)
 

Please note that all contributions to explain xkcd may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see explain xkcd:Copyrights for details). Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel | Editing help (opens in new window)

Template used on this page: