Calculate the Mean mean of two numbers












3












$begingroup$


disclaimer: the Mean mean is made up by me



Define the arithmetic mean of $n$ numbers as
$$M_1(x_1,...,x_n)=frac{x_1+x_2+...+x_n}{n}$$
Define the geometric mean of $n$ numbers as
$$M_0(x_1,...,x_n)=root{n}of{x_1x_2...x_n}$$
Define the harmonic mean of $n$ numbers as
$$M_{-1}(x_1,...,x_n)=frac{n}{frac{1}{x_2} + frac{1}{x_2} + ... + frac{1}{x_n}}$$
Define the quadratic mean of $n$ numbers as
$$M_2(x_1,...,x_n)=rootof{frac{x_1^2+x_2^2+...+x_n^2}{n}}$$
The Mean mean ($M_M$) is defined as follows:
Define four sequences ($a_k, b_k, c_k, d_k$) as $$a_0=M_1(x_1,...,x_n),\b_0=M_0(x_1,...,x_n),\c_0=M_{-1}(x_1,...,x_n),\d_0=M_2(x_1,...,x_n),\
a_{k+1}=M_1(a_k,b_k,c_k,d_k),\b_{k+1}=M_0(a_k,b_k,c_k,d_k),\c_{k+1}=M_{-1}(a_k,b_k,c_k,d_k),\d_{k+1}=M_2(a_k,b_k,c_k,d_k)$$

All four sequences converge to the same number, $M_M(x_1,x_2,...,x_n)$.



Example



The Mean mean of 1 and 2 is calculated as follows: start with $$a_0 = (1+2)/2 = 1.5, b_0 = rootof{1 * 2} = rootof2 approx 1.4142,\ c_0 = frac2{frac1{1}+frac1{2}} = frac4{3} approx 1.3333, d_0 = rootof{frac{1^2+2^2}2} = rootof{frac5{2}} approx 1.5811.$$
Then
$$a_1 = frac{1.5+1.4142+1.3333+1.5811}4 approx 1.4571,\ b_1 = root^4of{1.5*1.4142*1.3333*1.5811} approx 1.4542,\ c_1 = frac4{frac1{1.5}+frac1{1.4142}+frac1{1.3333}+frac1{1.5811}} approx 1.4512,\ d_1 = rootof{frac{1.5^2+1.4142^2+1.3333^2+1.5811^2}4} approx 1.4601.$$
The further calculation of the sequences should be clear. It can be seen that they converge to the same number, approximately $1.45568889$.



Challenge



Given two positive real numbers, $a$ and $b$, calculate their Mean mean $M_M(a,b)$.



Test cases



1 1 => 1
1 2 => 1.45568889
100 200 => 145.568889
2.71 3.14 => 2.92103713
0.57 1.78 => 1.0848205
1.61 2.41 => 1.98965438
0.01 100 => 6.7483058


This is code-golf, so the shortest code wins!










share|improve this question











$endgroup$












  • $begingroup$
    Sandbox link
    $endgroup$
    – someone
    8 hours ago










  • $begingroup$
    Somewhat related: Calculate the Arithmetic–Geometric Mean
    $endgroup$
    – user202729
    2 hours ago
















3












$begingroup$


disclaimer: the Mean mean is made up by me



Define the arithmetic mean of $n$ numbers as
$$M_1(x_1,...,x_n)=frac{x_1+x_2+...+x_n}{n}$$
Define the geometric mean of $n$ numbers as
$$M_0(x_1,...,x_n)=root{n}of{x_1x_2...x_n}$$
Define the harmonic mean of $n$ numbers as
$$M_{-1}(x_1,...,x_n)=frac{n}{frac{1}{x_2} + frac{1}{x_2} + ... + frac{1}{x_n}}$$
Define the quadratic mean of $n$ numbers as
$$M_2(x_1,...,x_n)=rootof{frac{x_1^2+x_2^2+...+x_n^2}{n}}$$
The Mean mean ($M_M$) is defined as follows:
Define four sequences ($a_k, b_k, c_k, d_k$) as $$a_0=M_1(x_1,...,x_n),\b_0=M_0(x_1,...,x_n),\c_0=M_{-1}(x_1,...,x_n),\d_0=M_2(x_1,...,x_n),\
a_{k+1}=M_1(a_k,b_k,c_k,d_k),\b_{k+1}=M_0(a_k,b_k,c_k,d_k),\c_{k+1}=M_{-1}(a_k,b_k,c_k,d_k),\d_{k+1}=M_2(a_k,b_k,c_k,d_k)$$

All four sequences converge to the same number, $M_M(x_1,x_2,...,x_n)$.



Example



The Mean mean of 1 and 2 is calculated as follows: start with $$a_0 = (1+2)/2 = 1.5, b_0 = rootof{1 * 2} = rootof2 approx 1.4142,\ c_0 = frac2{frac1{1}+frac1{2}} = frac4{3} approx 1.3333, d_0 = rootof{frac{1^2+2^2}2} = rootof{frac5{2}} approx 1.5811.$$
Then
$$a_1 = frac{1.5+1.4142+1.3333+1.5811}4 approx 1.4571,\ b_1 = root^4of{1.5*1.4142*1.3333*1.5811} approx 1.4542,\ c_1 = frac4{frac1{1.5}+frac1{1.4142}+frac1{1.3333}+frac1{1.5811}} approx 1.4512,\ d_1 = rootof{frac{1.5^2+1.4142^2+1.3333^2+1.5811^2}4} approx 1.4601.$$
The further calculation of the sequences should be clear. It can be seen that they converge to the same number, approximately $1.45568889$.



Challenge



Given two positive real numbers, $a$ and $b$, calculate their Mean mean $M_M(a,b)$.



Test cases



1 1 => 1
1 2 => 1.45568889
100 200 => 145.568889
2.71 3.14 => 2.92103713
0.57 1.78 => 1.0848205
1.61 2.41 => 1.98965438
0.01 100 => 6.7483058


This is code-golf, so the shortest code wins!










share|improve this question











$endgroup$












  • $begingroup$
    Sandbox link
    $endgroup$
    – someone
    8 hours ago










  • $begingroup$
    Somewhat related: Calculate the Arithmetic–Geometric Mean
    $endgroup$
    – user202729
    2 hours ago














3












3








3





$begingroup$


disclaimer: the Mean mean is made up by me



Define the arithmetic mean of $n$ numbers as
$$M_1(x_1,...,x_n)=frac{x_1+x_2+...+x_n}{n}$$
Define the geometric mean of $n$ numbers as
$$M_0(x_1,...,x_n)=root{n}of{x_1x_2...x_n}$$
Define the harmonic mean of $n$ numbers as
$$M_{-1}(x_1,...,x_n)=frac{n}{frac{1}{x_2} + frac{1}{x_2} + ... + frac{1}{x_n}}$$
Define the quadratic mean of $n$ numbers as
$$M_2(x_1,...,x_n)=rootof{frac{x_1^2+x_2^2+...+x_n^2}{n}}$$
The Mean mean ($M_M$) is defined as follows:
Define four sequences ($a_k, b_k, c_k, d_k$) as $$a_0=M_1(x_1,...,x_n),\b_0=M_0(x_1,...,x_n),\c_0=M_{-1}(x_1,...,x_n),\d_0=M_2(x_1,...,x_n),\
a_{k+1}=M_1(a_k,b_k,c_k,d_k),\b_{k+1}=M_0(a_k,b_k,c_k,d_k),\c_{k+1}=M_{-1}(a_k,b_k,c_k,d_k),\d_{k+1}=M_2(a_k,b_k,c_k,d_k)$$

All four sequences converge to the same number, $M_M(x_1,x_2,...,x_n)$.



Example



The Mean mean of 1 and 2 is calculated as follows: start with $$a_0 = (1+2)/2 = 1.5, b_0 = rootof{1 * 2} = rootof2 approx 1.4142,\ c_0 = frac2{frac1{1}+frac1{2}} = frac4{3} approx 1.3333, d_0 = rootof{frac{1^2+2^2}2} = rootof{frac5{2}} approx 1.5811.$$
Then
$$a_1 = frac{1.5+1.4142+1.3333+1.5811}4 approx 1.4571,\ b_1 = root^4of{1.5*1.4142*1.3333*1.5811} approx 1.4542,\ c_1 = frac4{frac1{1.5}+frac1{1.4142}+frac1{1.3333}+frac1{1.5811}} approx 1.4512,\ d_1 = rootof{frac{1.5^2+1.4142^2+1.3333^2+1.5811^2}4} approx 1.4601.$$
The further calculation of the sequences should be clear. It can be seen that they converge to the same number, approximately $1.45568889$.



Challenge



Given two positive real numbers, $a$ and $b$, calculate their Mean mean $M_M(a,b)$.



Test cases



1 1 => 1
1 2 => 1.45568889
100 200 => 145.568889
2.71 3.14 => 2.92103713
0.57 1.78 => 1.0848205
1.61 2.41 => 1.98965438
0.01 100 => 6.7483058


This is code-golf, so the shortest code wins!










share|improve this question











$endgroup$




disclaimer: the Mean mean is made up by me



Define the arithmetic mean of $n$ numbers as
$$M_1(x_1,...,x_n)=frac{x_1+x_2+...+x_n}{n}$$
Define the geometric mean of $n$ numbers as
$$M_0(x_1,...,x_n)=root{n}of{x_1x_2...x_n}$$
Define the harmonic mean of $n$ numbers as
$$M_{-1}(x_1,...,x_n)=frac{n}{frac{1}{x_2} + frac{1}{x_2} + ... + frac{1}{x_n}}$$
Define the quadratic mean of $n$ numbers as
$$M_2(x_1,...,x_n)=rootof{frac{x_1^2+x_2^2+...+x_n^2}{n}}$$
The Mean mean ($M_M$) is defined as follows:
Define four sequences ($a_k, b_k, c_k, d_k$) as $$a_0=M_1(x_1,...,x_n),\b_0=M_0(x_1,...,x_n),\c_0=M_{-1}(x_1,...,x_n),\d_0=M_2(x_1,...,x_n),\
a_{k+1}=M_1(a_k,b_k,c_k,d_k),\b_{k+1}=M_0(a_k,b_k,c_k,d_k),\c_{k+1}=M_{-1}(a_k,b_k,c_k,d_k),\d_{k+1}=M_2(a_k,b_k,c_k,d_k)$$

All four sequences converge to the same number, $M_M(x_1,x_2,...,x_n)$.



Example



The Mean mean of 1 and 2 is calculated as follows: start with $$a_0 = (1+2)/2 = 1.5, b_0 = rootof{1 * 2} = rootof2 approx 1.4142,\ c_0 = frac2{frac1{1}+frac1{2}} = frac4{3} approx 1.3333, d_0 = rootof{frac{1^2+2^2}2} = rootof{frac5{2}} approx 1.5811.$$
Then
$$a_1 = frac{1.5+1.4142+1.3333+1.5811}4 approx 1.4571,\ b_1 = root^4of{1.5*1.4142*1.3333*1.5811} approx 1.4542,\ c_1 = frac4{frac1{1.5}+frac1{1.4142}+frac1{1.3333}+frac1{1.5811}} approx 1.4512,\ d_1 = rootof{frac{1.5^2+1.4142^2+1.3333^2+1.5811^2}4} approx 1.4601.$$
The further calculation of the sequences should be clear. It can be seen that they converge to the same number, approximately $1.45568889$.



Challenge



Given two positive real numbers, $a$ and $b$, calculate their Mean mean $M_M(a,b)$.



Test cases



1 1 => 1
1 2 => 1.45568889
100 200 => 145.568889
2.71 3.14 => 2.92103713
0.57 1.78 => 1.0848205
1.61 2.41 => 1.98965438
0.01 100 => 6.7483058


This is code-golf, so the shortest code wins!







code-golf math






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 40 mins ago









Jonathan Allan

53.5k535172




53.5k535172










asked 8 hours ago









someonesomeone

557418




557418












  • $begingroup$
    Sandbox link
    $endgroup$
    – someone
    8 hours ago










  • $begingroup$
    Somewhat related: Calculate the Arithmetic–Geometric Mean
    $endgroup$
    – user202729
    2 hours ago


















  • $begingroup$
    Sandbox link
    $endgroup$
    – someone
    8 hours ago










  • $begingroup$
    Somewhat related: Calculate the Arithmetic–Geometric Mean
    $endgroup$
    – user202729
    2 hours ago
















$begingroup$
Sandbox link
$endgroup$
– someone
8 hours ago




$begingroup$
Sandbox link
$endgroup$
– someone
8 hours ago












$begingroup$
Somewhat related: Calculate the Arithmetic–Geometric Mean
$endgroup$
– user202729
2 hours ago




$begingroup$
Somewhat related: Calculate the Arithmetic–Geometric Mean
$endgroup$
– user202729
2 hours ago










5 Answers
5






active

oldest

votes


















1












$begingroup$


Wolfram Language (Mathematica), 77 bytes



#&@@N@Nest[{Mean@#,GeometricMean@#,HarmonicMean@#,RootMeanSquare@#}&,{##},9]&


Try it online!






share|improve this answer









$endgroup$





















    1












    $begingroup$


    Charcoal, 40 bytes



    W‹⌊θ⌈θ≔⟦∕ΣθLθXΠθ∕¹Lθ∕LθΣ∕¹θ₂∕ΣXθ²Lθ⟧θI⊟θ


    Try it online! Link is to verbose version of code. Takes input as an array of numbers. Explanation:



    W‹⌊θ⌈θ


    Repeat while the array contains different values...



    ≔⟦....⟧θ


    ... replace the array with a list of values:



    ∕ΣθLθ


    ... the mean...



    XΠθ∕¹Lθ


    ... the geometric mean...



    ∕LθΣ∕¹θ


    ... the harmonic mean...



    ₂∕ΣXθ²Lθ


    ... and the root mean square.



    I⊟θ


    Cast an element of the array to string and implicitly print it.






    share|improve this answer









    $endgroup$





















      0












      $begingroup$


      Jelly, 25 bytes



      Æm
      Ç;ÆlÇÆeƊ;²Ç½Ɗ;İÇİƊµÐLḢ


      Try it online!






      share|improve this answer











      $endgroup$













      • $begingroup$
        I am fairly bad at Jelly, but could something similar to P*İL work for the geometric mean?
        $endgroup$
        – someone
        1 hour ago












      • $begingroup$
        @someone it would need to be P*Lİ$ so wouldn’t save bytes. It would mean I could bring Æm back down a line without costing bytes, but I quite like the fact each one currently has an arithmetic mean at its core.
        $endgroup$
        – Nick Kennedy
        1 hour ago



















      0












      $begingroup$


      J, 34 bytes



      (31 as an expression without the assignment to variable f)



      f=:1{(^.z,%z,*:z,[z=:(+/%#)&.:)^:_


      Try it online!



      For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.






      share|improve this answer











      $endgroup$





















        0












        $begingroup$


        Jelly, 24 bytes



        ;µ*Ɱ-;ؽ¤©Æm*İɼ;P½½ƊµÐLḢ


        Try it online!






        share|improve this answer









        $endgroup$














          Your Answer





          StackExchange.ifUsing("editor", function () {
          return StackExchange.using("mathjaxEditing", function () {
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
          });
          });
          }, "mathjax-editing");

          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "200"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182460%2fcalculate-the-mean-mean-of-two-numbers%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1












          $begingroup$


          Wolfram Language (Mathematica), 77 bytes



          #&@@N@Nest[{Mean@#,GeometricMean@#,HarmonicMean@#,RootMeanSquare@#}&,{##},9]&


          Try it online!






          share|improve this answer









          $endgroup$


















            1












            $begingroup$


            Wolfram Language (Mathematica), 77 bytes



            #&@@N@Nest[{Mean@#,GeometricMean@#,HarmonicMean@#,RootMeanSquare@#}&,{##},9]&


            Try it online!






            share|improve this answer









            $endgroup$
















              1












              1








              1





              $begingroup$


              Wolfram Language (Mathematica), 77 bytes



              #&@@N@Nest[{Mean@#,GeometricMean@#,HarmonicMean@#,RootMeanSquare@#}&,{##},9]&


              Try it online!






              share|improve this answer









              $endgroup$




              Wolfram Language (Mathematica), 77 bytes



              #&@@N@Nest[{Mean@#,GeometricMean@#,HarmonicMean@#,RootMeanSquare@#}&,{##},9]&


              Try it online!







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered 7 hours ago









              J42161217J42161217

              13.6k21252




              13.6k21252























                  1












                  $begingroup$


                  Charcoal, 40 bytes



                  W‹⌊θ⌈θ≔⟦∕ΣθLθXΠθ∕¹Lθ∕LθΣ∕¹θ₂∕ΣXθ²Lθ⟧θI⊟θ


                  Try it online! Link is to verbose version of code. Takes input as an array of numbers. Explanation:



                  W‹⌊θ⌈θ


                  Repeat while the array contains different values...



                  ≔⟦....⟧θ


                  ... replace the array with a list of values:



                  ∕ΣθLθ


                  ... the mean...



                  XΠθ∕¹Lθ


                  ... the geometric mean...



                  ∕LθΣ∕¹θ


                  ... the harmonic mean...



                  ₂∕ΣXθ²Lθ


                  ... and the root mean square.



                  I⊟θ


                  Cast an element of the array to string and implicitly print it.






                  share|improve this answer









                  $endgroup$


















                    1












                    $begingroup$


                    Charcoal, 40 bytes



                    W‹⌊θ⌈θ≔⟦∕ΣθLθXΠθ∕¹Lθ∕LθΣ∕¹θ₂∕ΣXθ²Lθ⟧θI⊟θ


                    Try it online! Link is to verbose version of code. Takes input as an array of numbers. Explanation:



                    W‹⌊θ⌈θ


                    Repeat while the array contains different values...



                    ≔⟦....⟧θ


                    ... replace the array with a list of values:



                    ∕ΣθLθ


                    ... the mean...



                    XΠθ∕¹Lθ


                    ... the geometric mean...



                    ∕LθΣ∕¹θ


                    ... the harmonic mean...



                    ₂∕ΣXθ²Lθ


                    ... and the root mean square.



                    I⊟θ


                    Cast an element of the array to string and implicitly print it.






                    share|improve this answer









                    $endgroup$
















                      1












                      1








                      1





                      $begingroup$


                      Charcoal, 40 bytes



                      W‹⌊θ⌈θ≔⟦∕ΣθLθXΠθ∕¹Lθ∕LθΣ∕¹θ₂∕ΣXθ²Lθ⟧θI⊟θ


                      Try it online! Link is to verbose version of code. Takes input as an array of numbers. Explanation:



                      W‹⌊θ⌈θ


                      Repeat while the array contains different values...



                      ≔⟦....⟧θ


                      ... replace the array with a list of values:



                      ∕ΣθLθ


                      ... the mean...



                      XΠθ∕¹Lθ


                      ... the geometric mean...



                      ∕LθΣ∕¹θ


                      ... the harmonic mean...



                      ₂∕ΣXθ²Lθ


                      ... and the root mean square.



                      I⊟θ


                      Cast an element of the array to string and implicitly print it.






                      share|improve this answer









                      $endgroup$




                      Charcoal, 40 bytes



                      W‹⌊θ⌈θ≔⟦∕ΣθLθXΠθ∕¹Lθ∕LθΣ∕¹θ₂∕ΣXθ²Lθ⟧θI⊟θ


                      Try it online! Link is to verbose version of code. Takes input as an array of numbers. Explanation:



                      W‹⌊θ⌈θ


                      Repeat while the array contains different values...



                      ≔⟦....⟧θ


                      ... replace the array with a list of values:



                      ∕ΣθLθ


                      ... the mean...



                      XΠθ∕¹Lθ


                      ... the geometric mean...



                      ∕LθΣ∕¹θ


                      ... the harmonic mean...



                      ₂∕ΣXθ²Lθ


                      ... and the root mean square.



                      I⊟θ


                      Cast an element of the array to string and implicitly print it.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered 7 hours ago









                      NeilNeil

                      82.2k745178




                      82.2k745178























                          0












                          $begingroup$


                          Jelly, 25 bytes



                          Æm
                          Ç;ÆlÇÆeƊ;²Ç½Ɗ;İÇİƊµÐLḢ


                          Try it online!






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            I am fairly bad at Jelly, but could something similar to P*İL work for the geometric mean?
                            $endgroup$
                            – someone
                            1 hour ago












                          • $begingroup$
                            @someone it would need to be P*Lİ$ so wouldn’t save bytes. It would mean I could bring Æm back down a line without costing bytes, but I quite like the fact each one currently has an arithmetic mean at its core.
                            $endgroup$
                            – Nick Kennedy
                            1 hour ago
















                          0












                          $begingroup$


                          Jelly, 25 bytes



                          Æm
                          Ç;ÆlÇÆeƊ;²Ç½Ɗ;İÇİƊµÐLḢ


                          Try it online!






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            I am fairly bad at Jelly, but could something similar to P*İL work for the geometric mean?
                            $endgroup$
                            – someone
                            1 hour ago












                          • $begingroup$
                            @someone it would need to be P*Lİ$ so wouldn’t save bytes. It would mean I could bring Æm back down a line without costing bytes, but I quite like the fact each one currently has an arithmetic mean at its core.
                            $endgroup$
                            – Nick Kennedy
                            1 hour ago














                          0












                          0








                          0





                          $begingroup$


                          Jelly, 25 bytes



                          Æm
                          Ç;ÆlÇÆeƊ;²Ç½Ɗ;İÇİƊµÐLḢ


                          Try it online!






                          share|improve this answer











                          $endgroup$




                          Jelly, 25 bytes



                          Æm
                          Ç;ÆlÇÆeƊ;²Ç½Ɗ;İÇİƊµÐLḢ


                          Try it online!







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 1 hour ago

























                          answered 2 hours ago









                          Nick KennedyNick Kennedy

                          1,16649




                          1,16649












                          • $begingroup$
                            I am fairly bad at Jelly, but could something similar to P*İL work for the geometric mean?
                            $endgroup$
                            – someone
                            1 hour ago












                          • $begingroup$
                            @someone it would need to be P*Lİ$ so wouldn’t save bytes. It would mean I could bring Æm back down a line without costing bytes, but I quite like the fact each one currently has an arithmetic mean at its core.
                            $endgroup$
                            – Nick Kennedy
                            1 hour ago


















                          • $begingroup$
                            I am fairly bad at Jelly, but could something similar to P*İL work for the geometric mean?
                            $endgroup$
                            – someone
                            1 hour ago












                          • $begingroup$
                            @someone it would need to be P*Lİ$ so wouldn’t save bytes. It would mean I could bring Æm back down a line without costing bytes, but I quite like the fact each one currently has an arithmetic mean at its core.
                            $endgroup$
                            – Nick Kennedy
                            1 hour ago
















                          $begingroup$
                          I am fairly bad at Jelly, but could something similar to P*İL work for the geometric mean?
                          $endgroup$
                          – someone
                          1 hour ago






                          $begingroup$
                          I am fairly bad at Jelly, but could something similar to P*İL work for the geometric mean?
                          $endgroup$
                          – someone
                          1 hour ago














                          $begingroup$
                          @someone it would need to be P*Lİ$ so wouldn’t save bytes. It would mean I could bring Æm back down a line without costing bytes, but I quite like the fact each one currently has an arithmetic mean at its core.
                          $endgroup$
                          – Nick Kennedy
                          1 hour ago




                          $begingroup$
                          @someone it would need to be P*Lİ$ so wouldn’t save bytes. It would mean I could bring Æm back down a line without costing bytes, but I quite like the fact each one currently has an arithmetic mean at its core.
                          $endgroup$
                          – Nick Kennedy
                          1 hour ago











                          0












                          $begingroup$


                          J, 34 bytes



                          (31 as an expression without the assignment to variable f)



                          f=:1{(^.z,%z,*:z,[z=:(+/%#)&.:)^:_


                          Try it online!



                          For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.






                          share|improve this answer











                          $endgroup$


















                            0












                            $begingroup$


                            J, 34 bytes



                            (31 as an expression without the assignment to variable f)



                            f=:1{(^.z,%z,*:z,[z=:(+/%#)&.:)^:_


                            Try it online!



                            For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.






                            share|improve this answer











                            $endgroup$
















                              0












                              0








                              0





                              $begingroup$


                              J, 34 bytes



                              (31 as an expression without the assignment to variable f)



                              f=:1{(^.z,%z,*:z,[z=:(+/%#)&.:)^:_


                              Try it online!



                              For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.






                              share|improve this answer











                              $endgroup$




                              J, 34 bytes



                              (31 as an expression without the assignment to variable f)



                              f=:1{(^.z,%z,*:z,[z=:(+/%#)&.:)^:_


                              Try it online!



                              For functions a and b, a &.: b ("a under b" (related challenge)) is equivalent to (b inv) a b -- apply b, then a, then inverse of b. In this case, geometric/harmonic/quadratic mean is the arithmetic mean "under" logarithm, inversion, and square respectively.







                              share|improve this answer














                              share|improve this answer



                              share|improve this answer








                              edited 1 hour ago

























                              answered 2 hours ago









                              user202729user202729

                              14.1k12553




                              14.1k12553























                                  0












                                  $begingroup$


                                  Jelly, 24 bytes



                                  ;µ*Ɱ-;ؽ¤©Æm*İɼ;P½½ƊµÐLḢ


                                  Try it online!






                                  share|improve this answer









                                  $endgroup$


















                                    0












                                    $begingroup$


                                    Jelly, 24 bytes



                                    ;µ*Ɱ-;ؽ¤©Æm*İɼ;P½½ƊµÐLḢ


                                    Try it online!






                                    share|improve this answer









                                    $endgroup$
















                                      0












                                      0








                                      0





                                      $begingroup$


                                      Jelly, 24 bytes



                                      ;µ*Ɱ-;ؽ¤©Æm*İɼ;P½½ƊµÐLḢ


                                      Try it online!






                                      share|improve this answer









                                      $endgroup$




                                      Jelly, 24 bytes



                                      ;µ*Ɱ-;ؽ¤©Æm*İɼ;P½½ƊµÐLḢ


                                      Try it online!







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered 49 mins ago









                                      Erik the OutgolferErik the Outgolfer

                                      32.9k429106




                                      32.9k429106






























                                          draft saved

                                          draft discarded




















































                                          If this is an answer to a challenge…




                                          • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                          • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                            Explanations of your answer make it more interesting to read and are very much encouraged.


                                          • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                          More generally…




                                          • …Please make sure to answer the question and provide sufficient detail.


                                          • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function () {
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f182460%2fcalculate-the-mean-mean-of-two-numbers%23new-answer', 'question_page');
                                          }
                                          );

                                          Post as a guest















                                          Required, but never shown





















































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown

































                                          Required, but never shown














                                          Required, but never shown












                                          Required, but never shown







                                          Required, but never shown







                                          Popular posts from this blog

                                          Costa Masnaga

                                          Fotorealismo

                                          Sidney Franklin