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 204: Line 170:
  
 
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 246:
 
     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 348: Line 287:
 
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.
 
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.
+
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. [[Special:Contributions/141.101.98.16|141.101.98.16]]
 
 
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 364: Line 300:
 
:::'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 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]]
: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: