Maxima Manual: Functions and Variables for descriptive statistics

Next: Functions and Variables for specific multivariate descriptive statistics, Previous: Functions and Variables for data manipulation, Nach oben: Package descriptive [Inhalt][Index]

### 39.3 Functions and Variables for descriptive statistics

Function: mean (list)
Function: mean (matrix)

  This is the sample mean, defined as

                             n
                           ====
                   _   1   \
                   x = -    >    x
                       n   /      i
                           ====
                           i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) mean (s1);
                                     471
      (%o3)                          ---
                                     100

      (%i4) %, numer;
      (%o4)                         4.71

      (%i5) s2 : read_matrix (file_search ("wind.data"))$

      (%i6) mean (s2);
      (%o6)     [9.9485, 10.1607, 10.8685, 15.7166, 14.8441]

Function: var (list)
Function: var (matrix)

  This is the sample variance, defined as

                           n
                         ====
                 2   1   \          _ 2
                s  = -    >    (x - x)
                     n   /       i
                         ====
                         i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) var (s1), numer;
      (%o3)                   8.425899999999999

  See also function `var1`.

Function: var1 (list)
Function: var1 (matrix)

  This is the sample variance, defined as

                           n
                         ====
                     1   \          _ 2
                    ---   >    (x - x)
                    n-1  /       i
                         ====
                         i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) var1 (s1), numer;
      (%o3)                    8.5110101010101

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) var1 (s2);
      (%o5) [17.39586540404041, 15.13912778787879, 15.63204924242424,
                                  32.50152569696971, 24.66977392929294]

  See also function `var`.

Function: std (list)
Function: std (matrix)

  This is the the square root of function `var`, the variance with denominator n.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) std (s1), numer;
      (%o3)                   2.902740084816414

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) std (s2);
      (%o5) [4.149928523480858, 3.871399812729241, 3.933920277534866,
                                  5.672434260526957, 4.941970881136392]

  See also functions `var` and `std1`.

Function: std1 (list)
Function: std1 (matrix)

  This is the the square root of function `var1`, the variance with denominator n-1.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) std1 (s1), numer;
      (%o3)                   2.917363553109228

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) std1 (s2);
      (%o5) [4.170835096721089, 3.89090320978032, 3.953738641137555,
                                  5.701010936401517, 4.966867617451963]

  See also functions `var1` and `std`.

Function: noncentral_moment (list, k)
Function: noncentral_moment (matrix, k)

  The non central moment of order k, defined as

                             n
                           ====
                       1   \      k
                       -    >    x
                       n   /      i
                           ====
                           i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) noncentral_moment (s1, 1), numer; /* the mean */
      (%o3)                         4.71

      (%i5) s2 : read_matrix (file_search ("wind.data"))$

      (%i6) noncentral_moment (s2, 5);
      (%o6) [319793.8724761505, 320532.1923892463,
            391249.5621381556, 2502278.205988911, 1691881.797742255]

  See also function `central_moment`.

Function: central_moment (list, k)
Function: central_moment (matrix, k)

  The central moment of order k, defined as

                          n
                        ====
                    1   \          _ k
                    -    >    (x - x)
                    n   /       i
                        ====
                        i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) central_moment (s1, 2), numer; /* the variance */
      (%o3)                   8.425899999999999

      (%i5) s2 : read_matrix (file_search ("wind.data"))$

      (%i6) central_moment (s2, 3);
      (%o6) [11.29584771375004, 16.97988248298583, 5.626661952750102,
                                   37.5986572057918, 25.85981904394192]

  See also functions `central_moment` and `mean`.

Function: cv (list)
Function: cv (matrix)

  The variation coefficient is the quotient between the sample standard deviation (`std`) and the `mean`,

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) cv (s1), numer;
      (%o3)                   .6193977819764815

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) cv (s2);
      (%o5) [.4192426091090204, .3829365309260502, 0.363779605385983,
                                  .3627381836021478, .3346021393989506]

  See also functions `std` and `mean`.

Function: mini (list)
Function: mini (matrix)

  This is the minimum value of the sample list,

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) mini (s1);
      (%o3)                           0

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) mini (s2);
      (%o5)             [0.58, 0.5, 2.67, 5.25, 5.17]

  See also function `maxi`.

Function: maxi (list)
Function: maxi (matrix)

  This is the maximum value of the sample list,

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) maxi (s1);
      (%o3)                           9

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) maxi (s2);
      (%o5)          [20.25, 21.46, 20.04, 29.63, 27.63]

  See also function `mini`.

Function: range (list)
Function: range (matrix)

  The range is the difference between the extreme values.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) range (s1);
      (%o3)                           9

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) range (s2);
      (%o5)          [19.67, 20.96, 17.37, 24.38, 22.46]

Function: quantile (list, p)
Function: quantile (matrix, p)

  This is the p-quantile, with p a number in [0, 1], of the sample list. Although there are several definitions for the sample quantile (Hyndman, R. J., Fan, Y. (1996) Sample quantiles in statistical packages. American Statistician, 50, 361-365), the one based on linear interpolation is implemented in package `descriptive`.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) /* 1st and 3rd quartiles */
               [quantile (s1, 1/4), quantile (s1, 3/4)], numer;
      (%o3)                      [2.0, 7.25]

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) quantile (s2, 1/4);
      (%o5)    [7.2575, 7.477500000000001, 7.82, 11.28, 11.48]

Function: median (list)
Function: median (matrix)

  Once the sample is ordered, if the sample size is odd the median is the central value, otherwise it is the mean of the two central values.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) median (s1);
                                      9
      (%o3)                           -
                                      2

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) median (s2);
      (%o5)         [10.06, 9.855, 10.73, 15.48, 14.105]

  The median is the 1/2-quantile.

  See also function `quantile`.

Function: qrange (list)
Function: qrange (matrix)

  The interquartilic range is the difference between the third and first quartiles, `quantile(list,3/4) - quantile(list,1/4)`,

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) qrange (s1);
                                     21
      (%o3)                          --
                                     4

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) qrange (s2);
      (%o5) [5.385, 5.572499999999998, 6.022500000000001,
                                  8.729999999999999, 6.649999999999999]

  See also function `quantile`.

Function: mean_deviation (list)
Function: mean_deviation (matrix)

  The mean deviation, defined as

                           n
                         ====
                     1   \          _
                     -    >    |x - x|
                     n   /       i
                         ====
                         i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) mean_deviation (s1);
                                     51
      (%o3)                          --
                                     20

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) mean_deviation (s2);
      (%o5) [3.287959999999999, 3.075342, 3.23907, 4.715664000000001,
                                                     4.028546000000002]

  See also function `mean`.

Function: median_deviation (list)
Function: median_deviation (matrix)

  The median deviation, defined as

                       n
                     ====
                 1   \
                 -    >    |x - med|
                 n   /       i
                     ====
                     i = 1

  where `med` is the median of list.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) median_deviation (s1);
                                      5
      (%o3)                           -
                                      2

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) median_deviation (s2);
      (%o5)           [2.75, 2.755, 3.08, 4.315, 3.31]

  See also function `mean`.

Function: harmonic_mean (list)
Function: harmonic_mean (matrix)

  The harmonic mean, defined as

                        n
                     --------
                      n
                     ====
                     \     1
                      >    --
                     /     x
                     ====   i
                     i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) y : [5, 7, 2, 5, 9, 5, 6, 4, 9, 2, 4, 2, 5]$

      (%i3) harmonic_mean (y), numer;
      (%o3)                   3.901858027632205

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) harmonic_mean (s2);
      (%o5) [6.948015590052786, 7.391967752360356, 9.055658197151745,
                                  13.44199028193692, 13.01439145898509]

  See also functions `mean` and `geometric_mean`.

Function: geometric_mean (list)
Function: geometric_mean (matrix)

  The geometric mean, defined as

                       /  n      \ 1/n
                       | /===\   |
                       |  ! !    |
                       |  ! !  x |
                       |  ! !   i|
                       | i = 1   |
                       \         /

  Example:

      (%i1) load ("descriptive")$
      (%i2) y : [5, 7, 2, 5, 9, 5, 6, 4, 9, 2, 4, 2, 5]$

      (%i3) geometric_mean (y), numer;
      (%o3)                   4.454845412337012

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) geometric_mean (s2);
      (%o5) [8.82476274347979, 9.22652604739361, 10.0442675714889,
                                  14.61274126349021, 13.96184163444275]

  See also functions `mean` and `harmonic_mean`.

Function: kurtosis (list)
Function: kurtosis (matrix)

  The kurtosis coefficient, defined as

                          n
                        ====
                  1     \          _ 4
                 ----    >    (x - x)  - 3
                    4   /       i
                 n s    ====
                        i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) kurtosis (s1), numer;
      (%o3)                  - 1.273247946514421

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) kurtosis (s2);
      (%o5) [- .2715445622195385, 0.119998784429451,
         - .4275233490482861, - .6405361979019522, - .4952382132352935]

  See also functions `mean`, `var` and `skewness`.

Function: skewness (list)
Function: skewness (matrix)

  The skewness coefficient, defined as

                          n
                        ====
                  1     \          _ 3
                 ----    >    (x - x)
                    3   /       i
                 n s    ====
                        i = 1

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) skewness (s1), numer;
      (%o3)                  .009196180476450424

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) skewness (s2);
      (%o5) [.1580509020000978, .2926379232061854, .09242174416107717,
                                  .2059984348148687, .2142520248890831]

  See also functions `mean`, `var` and `kurtosis`.

Function: pearson_skewness (list)
Function: pearson_skewness (matrix)

  Pearson’s skewness coefficient, defined as

                      _
                   3 (x - med)
                   -----------
                        s

  where med is the median of list.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) pearson_skewness (s1), numer;
      (%o3)                   .2159484029093895

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) pearson_skewness (s2);
      (%o5) [- .08019976629211892, .2357036272952649,
               .1050904062491204, .1245042340592368, .4464181795804519]

  See also functions `mean`, `var` and `median`.

Function: quartile_skewness (list)
Function: quartile_skewness (matrix)

  The quartile skewness coefficient, defined as

                     c    - 2 c    + c
                      3/4      1/2    1/4
                     --------------------
                         c    - c
                          3/4    1/4

  where c_p is the p-quantile of sample list.

  Example:

      (%i1) load ("descriptive")$
      (%i2) s1 : read_list (file_search ("pidigits.data"))$

      (%i3) quartile_skewness (s1), numer;
      (%o3)                  .04761904761904762

      (%i4) s2 : read_matrix (file_search ("wind.data"))$

      (%i5) quartile_skewness (s2);
      (%o5) [- 0.0408542246982353, .1467025572005382,
             0.0336239103362392, .03780068728522298, .2105263157894735]

  See also function `quantile`.

Next: Functions and Variables for specific multivariate descriptive statistics, Previous: Functions and Variables for data manipulation, Nach oben: Package descriptive [Inhalt][Index]