Take single element of a list, and compare to average of whole list












2














If I have a list



lst = {1,2,3,4,5};


Is there someway of taking the first element and then comparing it to the average of the other 4? Then to take element 2 and compare it to the average of element 1,3,4,5? I can see how to do this with a For loop and a procedural style, but I am wondering if an easy functional style solution is possible.



Similar to This:



 1 == Mean[{2,3,4,5}]
2 == Mean[{1,3,4,5}]
3 == Mean[{1,2,4,5}]


PS. I plan on using a more elaborate comparison, but == seemed like an easy one for this example.










share|improve this question



























    2














    If I have a list



    lst = {1,2,3,4,5};


    Is there someway of taking the first element and then comparing it to the average of the other 4? Then to take element 2 and compare it to the average of element 1,3,4,5? I can see how to do this with a For loop and a procedural style, but I am wondering if an easy functional style solution is possible.



    Similar to This:



     1 == Mean[{2,3,4,5}]
    2 == Mean[{1,3,4,5}]
    3 == Mean[{1,2,4,5}]


    PS. I plan on using a more elaborate comparison, but == seemed like an easy one for this example.










    share|improve this question

























      2












      2








      2







      If I have a list



      lst = {1,2,3,4,5};


      Is there someway of taking the first element and then comparing it to the average of the other 4? Then to take element 2 and compare it to the average of element 1,3,4,5? I can see how to do this with a For loop and a procedural style, but I am wondering if an easy functional style solution is possible.



      Similar to This:



       1 == Mean[{2,3,4,5}]
      2 == Mean[{1,3,4,5}]
      3 == Mean[{1,2,4,5}]


      PS. I plan on using a more elaborate comparison, but == seemed like an easy one for this example.










      share|improve this question













      If I have a list



      lst = {1,2,3,4,5};


      Is there someway of taking the first element and then comparing it to the average of the other 4? Then to take element 2 and compare it to the average of element 1,3,4,5? I can see how to do this with a For loop and a procedural style, but I am wondering if an easy functional style solution is possible.



      Similar to This:



       1 == Mean[{2,3,4,5}]
      2 == Mean[{1,3,4,5}]
      3 == Mean[{1,2,4,5}]


      PS. I plan on using a more elaborate comparison, but == seemed like an easy one for this example.







      list-manipulation functional-style averages






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      olliepower

      1,21511127




      1,21511127






















          2 Answers
          2






          active

          oldest

          votes


















          2














          if you want to choose a specific element use



          F[x_] := Mean@Complement[lst, {x}]
          1 == F[1]
          2 == F[2]
          3 == F[3]



          False

          False

          True




          Note



          if you want to choose the first,second,nth element use



          F[x_] := Mean@Complement[lst, {lst[[x]]}]    
          1 == F[1]
          2 == F[2]
          3 == F[3]



          False

          False

          True







          share|improve this answer































            0














            ClearAll[subMeans]
            subMeans = (Total[#] - #)/(Length[#] - 1) &;


            Examples:



            lst = {a, b, c, d};
            subMeans[lst]



            {1/3 (b + c + d), 1/3 (a + c + d), 1/3 (a + b + d), 1/3 (a + b + c)}




            MapThread[Equal, {#, subMeans @ #}]& @ lst



            {a == 1/3 (b + c + d), b == 1/3 (a + c + d), c == 1/3 (a + b + d),
            d == 1/3 (a + b + c)}




            MapThread[Equal, {#, subMeans @ #}]& @ Range[5]



            {False, False, True, False, False}







            share|improve this answer























              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.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "387"
              };
              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%2fmathematica.stackexchange.com%2fquestions%2f188740%2ftake-single-element-of-a-list-and-compare-to-average-of-whole-list%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              if you want to choose a specific element use



              F[x_] := Mean@Complement[lst, {x}]
              1 == F[1]
              2 == F[2]
              3 == F[3]



              False

              False

              True




              Note



              if you want to choose the first,second,nth element use



              F[x_] := Mean@Complement[lst, {lst[[x]]}]    
              1 == F[1]
              2 == F[2]
              3 == F[3]



              False

              False

              True







              share|improve this answer




























                2














                if you want to choose a specific element use



                F[x_] := Mean@Complement[lst, {x}]
                1 == F[1]
                2 == F[2]
                3 == F[3]



                False

                False

                True




                Note



                if you want to choose the first,second,nth element use



                F[x_] := Mean@Complement[lst, {lst[[x]]}]    
                1 == F[1]
                2 == F[2]
                3 == F[3]



                False

                False

                True







                share|improve this answer


























                  2












                  2








                  2






                  if you want to choose a specific element use



                  F[x_] := Mean@Complement[lst, {x}]
                  1 == F[1]
                  2 == F[2]
                  3 == F[3]



                  False

                  False

                  True




                  Note



                  if you want to choose the first,second,nth element use



                  F[x_] := Mean@Complement[lst, {lst[[x]]}]    
                  1 == F[1]
                  2 == F[2]
                  3 == F[3]



                  False

                  False

                  True







                  share|improve this answer














                  if you want to choose a specific element use



                  F[x_] := Mean@Complement[lst, {x}]
                  1 == F[1]
                  2 == F[2]
                  3 == F[3]



                  False

                  False

                  True




                  Note



                  if you want to choose the first,second,nth element use



                  F[x_] := Mean@Complement[lst, {lst[[x]]}]    
                  1 == F[1]
                  2 == F[2]
                  3 == F[3]



                  False

                  False

                  True








                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited 2 hours ago

























                  answered 2 hours ago









                  J42161217

                  3,732220




                  3,732220























                      0














                      ClearAll[subMeans]
                      subMeans = (Total[#] - #)/(Length[#] - 1) &;


                      Examples:



                      lst = {a, b, c, d};
                      subMeans[lst]



                      {1/3 (b + c + d), 1/3 (a + c + d), 1/3 (a + b + d), 1/3 (a + b + c)}




                      MapThread[Equal, {#, subMeans @ #}]& @ lst



                      {a == 1/3 (b + c + d), b == 1/3 (a + c + d), c == 1/3 (a + b + d),
                      d == 1/3 (a + b + c)}




                      MapThread[Equal, {#, subMeans @ #}]& @ Range[5]



                      {False, False, True, False, False}







                      share|improve this answer




























                        0














                        ClearAll[subMeans]
                        subMeans = (Total[#] - #)/(Length[#] - 1) &;


                        Examples:



                        lst = {a, b, c, d};
                        subMeans[lst]



                        {1/3 (b + c + d), 1/3 (a + c + d), 1/3 (a + b + d), 1/3 (a + b + c)}




                        MapThread[Equal, {#, subMeans @ #}]& @ lst



                        {a == 1/3 (b + c + d), b == 1/3 (a + c + d), c == 1/3 (a + b + d),
                        d == 1/3 (a + b + c)}




                        MapThread[Equal, {#, subMeans @ #}]& @ Range[5]



                        {False, False, True, False, False}







                        share|improve this answer


























                          0












                          0








                          0






                          ClearAll[subMeans]
                          subMeans = (Total[#] - #)/(Length[#] - 1) &;


                          Examples:



                          lst = {a, b, c, d};
                          subMeans[lst]



                          {1/3 (b + c + d), 1/3 (a + c + d), 1/3 (a + b + d), 1/3 (a + b + c)}




                          MapThread[Equal, {#, subMeans @ #}]& @ lst



                          {a == 1/3 (b + c + d), b == 1/3 (a + c + d), c == 1/3 (a + b + d),
                          d == 1/3 (a + b + c)}




                          MapThread[Equal, {#, subMeans @ #}]& @ Range[5]



                          {False, False, True, False, False}







                          share|improve this answer














                          ClearAll[subMeans]
                          subMeans = (Total[#] - #)/(Length[#] - 1) &;


                          Examples:



                          lst = {a, b, c, d};
                          subMeans[lst]



                          {1/3 (b + c + d), 1/3 (a + c + d), 1/3 (a + b + d), 1/3 (a + b + c)}




                          MapThread[Equal, {#, subMeans @ #}]& @ lst



                          {a == 1/3 (b + c + d), b == 1/3 (a + c + d), c == 1/3 (a + b + d),
                          d == 1/3 (a + b + c)}




                          MapThread[Equal, {#, subMeans @ #}]& @ Range[5]



                          {False, False, True, False, False}








                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 57 mins ago

























                          answered 1 hour ago









                          kglr

                          177k9198405




                          177k9198405






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Mathematica Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              Use MathJax to format equations. MathJax reference.


                              To learn more, see our tips on writing great answers.





                              Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                              Please pay close attention to the following guidance:


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188740%2ftake-single-element-of-a-list-and-compare-to-average-of-whole-list%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

                              What visual should I use to simply compare current year value vs last year in Power BI desktop

                              How to ignore python UserWarning in pytest?

                              Alexandru Averescu