Calculating descriptive statistics











up vote
2
down vote

favorite
1












I'm writing a paper that involves many values. In order to be consistent in all the papers, I'm using def and xint to assign and calculate these values. However, in part of this paper I have to present some descriptive statistics about a dataset. And each time that one value in the dataset change, I have to recalculate all descriptive statistics and change many def. Then, my question is: Is possible to include the dataset in the latex and calculate all descriptive statistics (mean, mediam, min, max, and sum)?



for instance,
given the dataset [1,2,3,4,5,6,7]



I could calculate
Sample Size: 7,
Mean: 4,
Minimum: 1,
Maximum: 7,
Median: 4










share|improve this question
























  • Welcome to TeX.SX! That is an interesting question.
    – moewe
    Apr 22 '16 at 13:22










  • I think R program suits for calculation of summaries better. It has knitr or sweave compatible to LaTeX
    – Olga K
    Apr 22 '16 at 14:06










  • r-project.org, rstudio.com
    – Olga K
    Apr 22 '16 at 14:15










  • Do you always supply the data set in non-decreasing order?
    – Werner
    Apr 22 '16 at 14:34










  • Hello Olga, initially I solve my problem with the sagemath. However, Sagemath cloud site is not enoht to my needs. Then I could know that the Sharelatex now support natively the Knitr. And I did all calculation using this package.
    – user1032817
    May 25 '16 at 19:37















up vote
2
down vote

favorite
1












I'm writing a paper that involves many values. In order to be consistent in all the papers, I'm using def and xint to assign and calculate these values. However, in part of this paper I have to present some descriptive statistics about a dataset. And each time that one value in the dataset change, I have to recalculate all descriptive statistics and change many def. Then, my question is: Is possible to include the dataset in the latex and calculate all descriptive statistics (mean, mediam, min, max, and sum)?



for instance,
given the dataset [1,2,3,4,5,6,7]



I could calculate
Sample Size: 7,
Mean: 4,
Minimum: 1,
Maximum: 7,
Median: 4










share|improve this question
























  • Welcome to TeX.SX! That is an interesting question.
    – moewe
    Apr 22 '16 at 13:22










  • I think R program suits for calculation of summaries better. It has knitr or sweave compatible to LaTeX
    – Olga K
    Apr 22 '16 at 14:06










  • r-project.org, rstudio.com
    – Olga K
    Apr 22 '16 at 14:15










  • Do you always supply the data set in non-decreasing order?
    – Werner
    Apr 22 '16 at 14:34










  • Hello Olga, initially I solve my problem with the sagemath. However, Sagemath cloud site is not enoht to my needs. Then I could know that the Sharelatex now support natively the Knitr. And I did all calculation using this package.
    – user1032817
    May 25 '16 at 19:37













up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I'm writing a paper that involves many values. In order to be consistent in all the papers, I'm using def and xint to assign and calculate these values. However, in part of this paper I have to present some descriptive statistics about a dataset. And each time that one value in the dataset change, I have to recalculate all descriptive statistics and change many def. Then, my question is: Is possible to include the dataset in the latex and calculate all descriptive statistics (mean, mediam, min, max, and sum)?



for instance,
given the dataset [1,2,3,4,5,6,7]



I could calculate
Sample Size: 7,
Mean: 4,
Minimum: 1,
Maximum: 7,
Median: 4










share|improve this question















I'm writing a paper that involves many values. In order to be consistent in all the papers, I'm using def and xint to assign and calculate these values. However, in part of this paper I have to present some descriptive statistics about a dataset. And each time that one value in the dataset change, I have to recalculate all descriptive statistics and change many def. Then, my question is: Is possible to include the dataset in the latex and calculate all descriptive statistics (mean, mediam, min, max, and sum)?



for instance,
given the dataset [1,2,3,4,5,6,7]



I could calculate
Sample Size: 7,
Mean: 4,
Minimum: 1,
Maximum: 7,
Median: 4







programming xint






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









Andrew

29.3k34178




29.3k34178










asked Apr 22 '16 at 13:13









user1032817

133




133












  • Welcome to TeX.SX! That is an interesting question.
    – moewe
    Apr 22 '16 at 13:22










  • I think R program suits for calculation of summaries better. It has knitr or sweave compatible to LaTeX
    – Olga K
    Apr 22 '16 at 14:06










  • r-project.org, rstudio.com
    – Olga K
    Apr 22 '16 at 14:15










  • Do you always supply the data set in non-decreasing order?
    – Werner
    Apr 22 '16 at 14:34










  • Hello Olga, initially I solve my problem with the sagemath. However, Sagemath cloud site is not enoht to my needs. Then I could know that the Sharelatex now support natively the Knitr. And I did all calculation using this package.
    – user1032817
    May 25 '16 at 19:37


















  • Welcome to TeX.SX! That is an interesting question.
    – moewe
    Apr 22 '16 at 13:22










  • I think R program suits for calculation of summaries better. It has knitr or sweave compatible to LaTeX
    – Olga K
    Apr 22 '16 at 14:06










  • r-project.org, rstudio.com
    – Olga K
    Apr 22 '16 at 14:15










  • Do you always supply the data set in non-decreasing order?
    – Werner
    Apr 22 '16 at 14:34










  • Hello Olga, initially I solve my problem with the sagemath. However, Sagemath cloud site is not enoht to my needs. Then I could know that the Sharelatex now support natively the Knitr. And I did all calculation using this package.
    – user1032817
    May 25 '16 at 19:37
















Welcome to TeX.SX! That is an interesting question.
– moewe
Apr 22 '16 at 13:22




Welcome to TeX.SX! That is an interesting question.
– moewe
Apr 22 '16 at 13:22












I think R program suits for calculation of summaries better. It has knitr or sweave compatible to LaTeX
– Olga K
Apr 22 '16 at 14:06




I think R program suits for calculation of summaries better. It has knitr or sweave compatible to LaTeX
– Olga K
Apr 22 '16 at 14:06












r-project.org, rstudio.com
– Olga K
Apr 22 '16 at 14:15




r-project.org, rstudio.com
– Olga K
Apr 22 '16 at 14:15












Do you always supply the data set in non-decreasing order?
– Werner
Apr 22 '16 at 14:34




Do you always supply the data set in non-decreasing order?
– Werner
Apr 22 '16 at 14:34












Hello Olga, initially I solve my problem with the sagemath. However, Sagemath cloud site is not enoht to my needs. Then I could know that the Sharelatex now support natively the Knitr. And I did all calculation using this package.
– user1032817
May 25 '16 at 19:37




Hello Olga, initially I solve my problem with the sagemath. However, Sagemath cloud site is not enoht to my needs. Then I could know that the Sharelatex now support natively the Knitr. And I did all calculation using this package.
– user1032817
May 25 '16 at 19:37










1 Answer
1






active

oldest

votes

















up vote
6
down vote



accepted










If you're mixing math and LaTeX you should consider looking into the sagetex package which gives you access to a computer algebra system, called Sage, to handle the math. Documentation on basic statistics is here. You'll need Sage installed locally on your computer or, better yet, you use the free Sagemath Cloud site. In that case, no Sage to download and install.



documentclass{article}
usepackage{sagetex}
usepackage{graphicx}
begin{document}
begin{sagesilent}
MyData = [1,2,3,4,5,6,7]
end{sagesilent}

noindent My data set is $S = sage{MyData}$. For this data:\
The sample size is $sage{len(MyData)}$.\
The mean is $sage{mean(MyData)}$.\
The median is $sage{median(MyData)}$.\
The minimum value is $sage{min(MyData)}$.\
The maximum value is $sage{max(MyData)}$.\
The standarad deviation of the sample is $sage{std(MyData)}$.\
The sum of the data values is $sage{sum(MyData)}$.
end{document}


The output is shown running in Sagemath Cloud; as you can see, the code is short and easily understood.
enter image description here



EDIT: I forgot to compute the median. That is easily accomplished with an extra line.






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "85"
    };
    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',
    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%2ftex.stackexchange.com%2fquestions%2f305764%2fcalculating-descriptive-statistics%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote



    accepted










    If you're mixing math and LaTeX you should consider looking into the sagetex package which gives you access to a computer algebra system, called Sage, to handle the math. Documentation on basic statistics is here. You'll need Sage installed locally on your computer or, better yet, you use the free Sagemath Cloud site. In that case, no Sage to download and install.



    documentclass{article}
    usepackage{sagetex}
    usepackage{graphicx}
    begin{document}
    begin{sagesilent}
    MyData = [1,2,3,4,5,6,7]
    end{sagesilent}

    noindent My data set is $S = sage{MyData}$. For this data:\
    The sample size is $sage{len(MyData)}$.\
    The mean is $sage{mean(MyData)}$.\
    The median is $sage{median(MyData)}$.\
    The minimum value is $sage{min(MyData)}$.\
    The maximum value is $sage{max(MyData)}$.\
    The standarad deviation of the sample is $sage{std(MyData)}$.\
    The sum of the data values is $sage{sum(MyData)}$.
    end{document}


    The output is shown running in Sagemath Cloud; as you can see, the code is short and easily understood.
    enter image description here



    EDIT: I forgot to compute the median. That is easily accomplished with an extra line.






    share|improve this answer



























      up vote
      6
      down vote



      accepted










      If you're mixing math and LaTeX you should consider looking into the sagetex package which gives you access to a computer algebra system, called Sage, to handle the math. Documentation on basic statistics is here. You'll need Sage installed locally on your computer or, better yet, you use the free Sagemath Cloud site. In that case, no Sage to download and install.



      documentclass{article}
      usepackage{sagetex}
      usepackage{graphicx}
      begin{document}
      begin{sagesilent}
      MyData = [1,2,3,4,5,6,7]
      end{sagesilent}

      noindent My data set is $S = sage{MyData}$. For this data:\
      The sample size is $sage{len(MyData)}$.\
      The mean is $sage{mean(MyData)}$.\
      The median is $sage{median(MyData)}$.\
      The minimum value is $sage{min(MyData)}$.\
      The maximum value is $sage{max(MyData)}$.\
      The standarad deviation of the sample is $sage{std(MyData)}$.\
      The sum of the data values is $sage{sum(MyData)}$.
      end{document}


      The output is shown running in Sagemath Cloud; as you can see, the code is short and easily understood.
      enter image description here



      EDIT: I forgot to compute the median. That is easily accomplished with an extra line.






      share|improve this answer

























        up vote
        6
        down vote



        accepted







        up vote
        6
        down vote



        accepted






        If you're mixing math and LaTeX you should consider looking into the sagetex package which gives you access to a computer algebra system, called Sage, to handle the math. Documentation on basic statistics is here. You'll need Sage installed locally on your computer or, better yet, you use the free Sagemath Cloud site. In that case, no Sage to download and install.



        documentclass{article}
        usepackage{sagetex}
        usepackage{graphicx}
        begin{document}
        begin{sagesilent}
        MyData = [1,2,3,4,5,6,7]
        end{sagesilent}

        noindent My data set is $S = sage{MyData}$. For this data:\
        The sample size is $sage{len(MyData)}$.\
        The mean is $sage{mean(MyData)}$.\
        The median is $sage{median(MyData)}$.\
        The minimum value is $sage{min(MyData)}$.\
        The maximum value is $sage{max(MyData)}$.\
        The standarad deviation of the sample is $sage{std(MyData)}$.\
        The sum of the data values is $sage{sum(MyData)}$.
        end{document}


        The output is shown running in Sagemath Cloud; as you can see, the code is short and easily understood.
        enter image description here



        EDIT: I forgot to compute the median. That is easily accomplished with an extra line.






        share|improve this answer














        If you're mixing math and LaTeX you should consider looking into the sagetex package which gives you access to a computer algebra system, called Sage, to handle the math. Documentation on basic statistics is here. You'll need Sage installed locally on your computer or, better yet, you use the free Sagemath Cloud site. In that case, no Sage to download and install.



        documentclass{article}
        usepackage{sagetex}
        usepackage{graphicx}
        begin{document}
        begin{sagesilent}
        MyData = [1,2,3,4,5,6,7]
        end{sagesilent}

        noindent My data set is $S = sage{MyData}$. For this data:\
        The sample size is $sage{len(MyData)}$.\
        The mean is $sage{mean(MyData)}$.\
        The median is $sage{median(MyData)}$.\
        The minimum value is $sage{min(MyData)}$.\
        The maximum value is $sage{max(MyData)}$.\
        The standarad deviation of the sample is $sage{std(MyData)}$.\
        The sum of the data values is $sage{sum(MyData)}$.
        end{document}


        The output is shown running in Sagemath Cloud; as you can see, the code is short and easily understood.
        enter image description here



        EDIT: I forgot to compute the median. That is easily accomplished with an extra line.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 23 '16 at 0:00

























        answered Apr 22 '16 at 14:06









        DJP

        6,89921629




        6,89921629






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f305764%2fcalculating-descriptive-statistics%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

            Accessing regular linux commands in Huawei's Dopra Linux

            Can't connect RFCOMM socket: Host is down

            Kernel panic - not syncing: Fatal Exception in Interrupt