How to construct and plot the following accumulated list?












2












$begingroup$


I have a list, say it is



a = {1,3,3.2,3.9,4,4.4,4.9,5,7,8}


To get the accumulate:



acc = Accumlate[a]


I want to plot the number of elements less than or equal to a certain element against the accumulated value of the list elements.
The pairs should look like (acc[[i]], number of elements less than a[[i]]). For instance, (1, 1), (4, 2), (7.2,3), etc.



Then I want to take the derivative of the plot to plot it as well.










share|improve this question











$endgroup$








  • 1




    $begingroup$
    The plotting is not a problem see ListPlot. Also, if you want a derivative you will have to define this as you don't have a continuous function. What have you tried so far?
    $endgroup$
    – Hugh
    Apr 13 at 11:26










  • $begingroup$
    The plot is an issue when I have very large number of pairs like 1000 pairs. I am trying to do it using ListPlot and a Do loop but it does not work. I am doing: ListLinePlot[{Do[Print[{acc[[i]], Count[a[[i]]}], {i, 10}]}] but it only prints the pairs for me with an empty plot.
    $endgroup$
    – Hamza
    Apr 13 at 12:04










  • $begingroup$
    Your combined use of Do and Print doesn't do what you expect. Print merely prints to the screen but does not build a list; use Table instead. Also, Count is something else.
    $endgroup$
    – Roman
    Apr 13 at 16:29
















2












$begingroup$


I have a list, say it is



a = {1,3,3.2,3.9,4,4.4,4.9,5,7,8}


To get the accumulate:



acc = Accumlate[a]


I want to plot the number of elements less than or equal to a certain element against the accumulated value of the list elements.
The pairs should look like (acc[[i]], number of elements less than a[[i]]). For instance, (1, 1), (4, 2), (7.2,3), etc.



Then I want to take the derivative of the plot to plot it as well.










share|improve this question











$endgroup$








  • 1




    $begingroup$
    The plotting is not a problem see ListPlot. Also, if you want a derivative you will have to define this as you don't have a continuous function. What have you tried so far?
    $endgroup$
    – Hugh
    Apr 13 at 11:26










  • $begingroup$
    The plot is an issue when I have very large number of pairs like 1000 pairs. I am trying to do it using ListPlot and a Do loop but it does not work. I am doing: ListLinePlot[{Do[Print[{acc[[i]], Count[a[[i]]}], {i, 10}]}] but it only prints the pairs for me with an empty plot.
    $endgroup$
    – Hamza
    Apr 13 at 12:04










  • $begingroup$
    Your combined use of Do and Print doesn't do what you expect. Print merely prints to the screen but does not build a list; use Table instead. Also, Count is something else.
    $endgroup$
    – Roman
    Apr 13 at 16:29














2












2








2





$begingroup$


I have a list, say it is



a = {1,3,3.2,3.9,4,4.4,4.9,5,7,8}


To get the accumulate:



acc = Accumlate[a]


I want to plot the number of elements less than or equal to a certain element against the accumulated value of the list elements.
The pairs should look like (acc[[i]], number of elements less than a[[i]]). For instance, (1, 1), (4, 2), (7.2,3), etc.



Then I want to take the derivative of the plot to plot it as well.










share|improve this question











$endgroup$




I have a list, say it is



a = {1,3,3.2,3.9,4,4.4,4.9,5,7,8}


To get the accumulate:



acc = Accumlate[a]


I want to plot the number of elements less than or equal to a certain element against the accumulated value of the list elements.
The pairs should look like (acc[[i]], number of elements less than a[[i]]). For instance, (1, 1), (4, 2), (7.2,3), etc.



Then I want to take the derivative of the plot to plot it as well.







plotting list-manipulation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 13 at 16:26









Roman

5,62611131




5,62611131










asked Apr 13 at 11:22









HamzaHamza

225




225








  • 1




    $begingroup$
    The plotting is not a problem see ListPlot. Also, if you want a derivative you will have to define this as you don't have a continuous function. What have you tried so far?
    $endgroup$
    – Hugh
    Apr 13 at 11:26










  • $begingroup$
    The plot is an issue when I have very large number of pairs like 1000 pairs. I am trying to do it using ListPlot and a Do loop but it does not work. I am doing: ListLinePlot[{Do[Print[{acc[[i]], Count[a[[i]]}], {i, 10}]}] but it only prints the pairs for me with an empty plot.
    $endgroup$
    – Hamza
    Apr 13 at 12:04










  • $begingroup$
    Your combined use of Do and Print doesn't do what you expect. Print merely prints to the screen but does not build a list; use Table instead. Also, Count is something else.
    $endgroup$
    – Roman
    Apr 13 at 16:29














  • 1




    $begingroup$
    The plotting is not a problem see ListPlot. Also, if you want a derivative you will have to define this as you don't have a continuous function. What have you tried so far?
    $endgroup$
    – Hugh
    Apr 13 at 11:26










  • $begingroup$
    The plot is an issue when I have very large number of pairs like 1000 pairs. I am trying to do it using ListPlot and a Do loop but it does not work. I am doing: ListLinePlot[{Do[Print[{acc[[i]], Count[a[[i]]}], {i, 10}]}] but it only prints the pairs for me with an empty plot.
    $endgroup$
    – Hamza
    Apr 13 at 12:04










  • $begingroup$
    Your combined use of Do and Print doesn't do what you expect. Print merely prints to the screen but does not build a list; use Table instead. Also, Count is something else.
    $endgroup$
    – Roman
    Apr 13 at 16:29








1




1




$begingroup$
The plotting is not a problem see ListPlot. Also, if you want a derivative you will have to define this as you don't have a continuous function. What have you tried so far?
$endgroup$
– Hugh
Apr 13 at 11:26




$begingroup$
The plotting is not a problem see ListPlot. Also, if you want a derivative you will have to define this as you don't have a continuous function. What have you tried so far?
$endgroup$
– Hugh
Apr 13 at 11:26












$begingroup$
The plot is an issue when I have very large number of pairs like 1000 pairs. I am trying to do it using ListPlot and a Do loop but it does not work. I am doing: ListLinePlot[{Do[Print[{acc[[i]], Count[a[[i]]}], {i, 10}]}] but it only prints the pairs for me with an empty plot.
$endgroup$
– Hamza
Apr 13 at 12:04




$begingroup$
The plot is an issue when I have very large number of pairs like 1000 pairs. I am trying to do it using ListPlot and a Do loop but it does not work. I am doing: ListLinePlot[{Do[Print[{acc[[i]], Count[a[[i]]}], {i, 10}]}] but it only prints the pairs for me with an empty plot.
$endgroup$
– Hamza
Apr 13 at 12:04












$begingroup$
Your combined use of Do and Print doesn't do what you expect. Print merely prints to the screen but does not build a list; use Table instead. Also, Count is something else.
$endgroup$
– Roman
Apr 13 at 16:29




$begingroup$
Your combined use of Do and Print doesn't do what you expect. Print merely prints to the screen but does not build a list; use Table instead. Also, Count is something else.
$endgroup$
– Roman
Apr 13 at 16:29










2 Answers
2






active

oldest

votes


















1












$begingroup$

Assuming that there are no duplicate elements in the list, and that the list is sorted in ascending order:



ListLinePlot[Transpose[{Accumulate[a], Range[Length[a]]}]]


If the list isn't sorted, you should replace Accumulate[a] with Accumulate[Sort[a]].



enter image description here



If you need the derivative, it may be easier to first construct an interpolating function. Here I make the interpolation linear (InterpolationOrder -> 1) but you can change this. You can get the above plot with Plot[b[x], {x, 1, Total[a]}] and the first-derivative plot with



b = Interpolation[Transpose[{Accumulate[Sort[a]], Range[Length[a]]}], 
InterpolationOrder -> 1];
Plot[b'[x], {x, 1, Total[a]}]


enter image description here






share|improve this answer











$endgroup$





















    3












    $begingroup$

    try this



    a = {1, 3, 3.2, 3.9, 4, 4.4, 4.9, 5, 7, 8};
    acc = Accumulate@a;
    aa[x_] := Length@Select[a, # <= a[[x]] &];
    list = Transpose[{acc, aa /@ Range@Length@a}]
    ListLinePlot@list



    {{1,1},{4,2},{7.2,3},{11.1,4},{15.1,5},{19.5,6},{24.4,7},{29.4,8},{36.4,9},{44.4,10}}




    enter image description here






    share|improve this answer











    $endgroup$













    • $begingroup$
      The y-axis should represent the number of elements less than or equal a[[i]] not the element itself.
      $endgroup$
      – Hamza
      Apr 13 at 13:57










    • $begingroup$
      @Hamza fixed....
      $endgroup$
      – J42161217
      Apr 13 at 14:12












    Your Answer








    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%2f195111%2fhow-to-construct-and-plot-the-following-accumulated-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









    1












    $begingroup$

    Assuming that there are no duplicate elements in the list, and that the list is sorted in ascending order:



    ListLinePlot[Transpose[{Accumulate[a], Range[Length[a]]}]]


    If the list isn't sorted, you should replace Accumulate[a] with Accumulate[Sort[a]].



    enter image description here



    If you need the derivative, it may be easier to first construct an interpolating function. Here I make the interpolation linear (InterpolationOrder -> 1) but you can change this. You can get the above plot with Plot[b[x], {x, 1, Total[a]}] and the first-derivative plot with



    b = Interpolation[Transpose[{Accumulate[Sort[a]], Range[Length[a]]}], 
    InterpolationOrder -> 1];
    Plot[b'[x], {x, 1, Total[a]}]


    enter image description here






    share|improve this answer











    $endgroup$


















      1












      $begingroup$

      Assuming that there are no duplicate elements in the list, and that the list is sorted in ascending order:



      ListLinePlot[Transpose[{Accumulate[a], Range[Length[a]]}]]


      If the list isn't sorted, you should replace Accumulate[a] with Accumulate[Sort[a]].



      enter image description here



      If you need the derivative, it may be easier to first construct an interpolating function. Here I make the interpolation linear (InterpolationOrder -> 1) but you can change this. You can get the above plot with Plot[b[x], {x, 1, Total[a]}] and the first-derivative plot with



      b = Interpolation[Transpose[{Accumulate[Sort[a]], Range[Length[a]]}], 
      InterpolationOrder -> 1];
      Plot[b'[x], {x, 1, Total[a]}]


      enter image description here






      share|improve this answer











      $endgroup$
















        1












        1








        1





        $begingroup$

        Assuming that there are no duplicate elements in the list, and that the list is sorted in ascending order:



        ListLinePlot[Transpose[{Accumulate[a], Range[Length[a]]}]]


        If the list isn't sorted, you should replace Accumulate[a] with Accumulate[Sort[a]].



        enter image description here



        If you need the derivative, it may be easier to first construct an interpolating function. Here I make the interpolation linear (InterpolationOrder -> 1) but you can change this. You can get the above plot with Plot[b[x], {x, 1, Total[a]}] and the first-derivative plot with



        b = Interpolation[Transpose[{Accumulate[Sort[a]], Range[Length[a]]}], 
        InterpolationOrder -> 1];
        Plot[b'[x], {x, 1, Total[a]}]


        enter image description here






        share|improve this answer











        $endgroup$



        Assuming that there are no duplicate elements in the list, and that the list is sorted in ascending order:



        ListLinePlot[Transpose[{Accumulate[a], Range[Length[a]]}]]


        If the list isn't sorted, you should replace Accumulate[a] with Accumulate[Sort[a]].



        enter image description here



        If you need the derivative, it may be easier to first construct an interpolating function. Here I make the interpolation linear (InterpolationOrder -> 1) but you can change this. You can get the above plot with Plot[b[x], {x, 1, Total[a]}] and the first-derivative plot with



        b = Interpolation[Transpose[{Accumulate[Sort[a]], Range[Length[a]]}], 
        InterpolationOrder -> 1];
        Plot[b'[x], {x, 1, Total[a]}]


        enter image description here







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 13 at 16:30

























        answered Apr 13 at 16:18









        RomanRoman

        5,62611131




        5,62611131























            3












            $begingroup$

            try this



            a = {1, 3, 3.2, 3.9, 4, 4.4, 4.9, 5, 7, 8};
            acc = Accumulate@a;
            aa[x_] := Length@Select[a, # <= a[[x]] &];
            list = Transpose[{acc, aa /@ Range@Length@a}]
            ListLinePlot@list



            {{1,1},{4,2},{7.2,3},{11.1,4},{15.1,5},{19.5,6},{24.4,7},{29.4,8},{36.4,9},{44.4,10}}




            enter image description here






            share|improve this answer











            $endgroup$













            • $begingroup$
              The y-axis should represent the number of elements less than or equal a[[i]] not the element itself.
              $endgroup$
              – Hamza
              Apr 13 at 13:57










            • $begingroup$
              @Hamza fixed....
              $endgroup$
              – J42161217
              Apr 13 at 14:12
















            3












            $begingroup$

            try this



            a = {1, 3, 3.2, 3.9, 4, 4.4, 4.9, 5, 7, 8};
            acc = Accumulate@a;
            aa[x_] := Length@Select[a, # <= a[[x]] &];
            list = Transpose[{acc, aa /@ Range@Length@a}]
            ListLinePlot@list



            {{1,1},{4,2},{7.2,3},{11.1,4},{15.1,5},{19.5,6},{24.4,7},{29.4,8},{36.4,9},{44.4,10}}




            enter image description here






            share|improve this answer











            $endgroup$













            • $begingroup$
              The y-axis should represent the number of elements less than or equal a[[i]] not the element itself.
              $endgroup$
              – Hamza
              Apr 13 at 13:57










            • $begingroup$
              @Hamza fixed....
              $endgroup$
              – J42161217
              Apr 13 at 14:12














            3












            3








            3





            $begingroup$

            try this



            a = {1, 3, 3.2, 3.9, 4, 4.4, 4.9, 5, 7, 8};
            acc = Accumulate@a;
            aa[x_] := Length@Select[a, # <= a[[x]] &];
            list = Transpose[{acc, aa /@ Range@Length@a}]
            ListLinePlot@list



            {{1,1},{4,2},{7.2,3},{11.1,4},{15.1,5},{19.5,6},{24.4,7},{29.4,8},{36.4,9},{44.4,10}}




            enter image description here






            share|improve this answer











            $endgroup$



            try this



            a = {1, 3, 3.2, 3.9, 4, 4.4, 4.9, 5, 7, 8};
            acc = Accumulate@a;
            aa[x_] := Length@Select[a, # <= a[[x]] &];
            list = Transpose[{acc, aa /@ Range@Length@a}]
            ListLinePlot@list



            {{1,1},{4,2},{7.2,3},{11.1,4},{15.1,5},{19.5,6},{24.4,7},{29.4,8},{36.4,9},{44.4,10}}




            enter image description here







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 13 at 14:12

























            answered Apr 13 at 12:45









            J42161217J42161217

            4,598324




            4,598324












            • $begingroup$
              The y-axis should represent the number of elements less than or equal a[[i]] not the element itself.
              $endgroup$
              – Hamza
              Apr 13 at 13:57










            • $begingroup$
              @Hamza fixed....
              $endgroup$
              – J42161217
              Apr 13 at 14:12


















            • $begingroup$
              The y-axis should represent the number of elements less than or equal a[[i]] not the element itself.
              $endgroup$
              – Hamza
              Apr 13 at 13:57










            • $begingroup$
              @Hamza fixed....
              $endgroup$
              – J42161217
              Apr 13 at 14:12
















            $begingroup$
            The y-axis should represent the number of elements less than or equal a[[i]] not the element itself.
            $endgroup$
            – Hamza
            Apr 13 at 13:57




            $begingroup$
            The y-axis should represent the number of elements less than or equal a[[i]] not the element itself.
            $endgroup$
            – Hamza
            Apr 13 at 13:57












            $begingroup$
            @Hamza fixed....
            $endgroup$
            – J42161217
            Apr 13 at 14:12




            $begingroup$
            @Hamza fixed....
            $endgroup$
            – J42161217
            Apr 13 at 14:12


















            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.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f195111%2fhow-to-construct-and-plot-the-following-accumulated-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

            Plaza Victoria

            Puebla de Zaragoza

            Musa