Statistical Functions

Table of Contents

  1. Introduction
  2. am(x[,verb_rank])
  3. median(x[,verb_rank])
  4. gm(x[,verb_rank])
  5. rms(x[,verb_rank])
  6. sd(x[,verb_rank])
  7. sd1(x[,verb_rank])
  8. var(x[,verb_rank])
  9. var1(x[,verb_rank])

Introduction

These are defined in stat.tcl. Note that there is also a built-in statistical function called correlation.

Three examples are provided for each function. The first uses the vector v which is defined as follows (note the missing values):

% nap "v = {12 6 _ 7 3 15 _ 10 18 5}"
::NAP::14-14
% $v all -c -1
::NAP::14-14  i32  MissingValue: -2147483648  References: 1  Unit: (NULL)
Dimension 0   Size: 10     Name: (NULL)    Coordinate-variable: (NULL)
Value:
12 6 _ 7 3 15 _ 10 18 5

The second example produces statistics of each column of a matrix. The second example produces statistics of each row of a matrix. The matrix is called m and is defined as follows:

% nap "m = {
    {1.5 2.1 -5}
    {5.5 9.4  0}
}"
::NAP::15-15
% $m all -c -1
::NAP::15-15  f64  MissingValue: NaN  References: 1  Unit: (NULL)
Dimension 0   Size: 2      Name: (NULL)    Coordinate-variable: (NULL)
Dimension 1   Size: 3      Name: (NULL)    Coordinate-variable: (NULL)
Value:
 1.5  2.1 -5.0
 5.5  9.4  0.0

am(x[,verb_rank])

Arithmetic mean.
% [nap "am(v)"]
9.5
% [nap "am(m)"]
3.5 5.75 -2.5
% [nap "am(m,1)"]
-0.466667 4.96667

median(x[,verb_rank])

Median.
% [nap "median(v)"]
8.5
% [nap "median(m)"]
3.5 5.75 -2.5
% [nap "median(m,1)"]
1.5 5.5

gm(x[,verb_rank])

Geometric mean.
% [nap "gm(v)"]
8.19852
% [nap "gm(m)"]
2.87228 4.44297 0
% [nap "gm(m,1)"]
_ 0

rms(x[,verb_rank])

Root mean square.
% [nap "rms(v)"]
10.6771
% [nap "rms(m)"]
4.03113 6.81065 3.53553
% [nap "rms(m,1)"]
3.24859 6.28782

sd(x[,verb_rank])

Standard-deviation (with division by n).
% [nap "sd(v)"]
4.8734
% [nap "sd(m)"]
2 3.65 2.5
% [nap "sd(m,1)"]
3.2149 3.85602

sd1(x[,verb_rank])

Standard-deviation (with division by n-1).
% [nap "sd1(v)"]
5.20988
% [nap "sd1(m)"]
2.82843 5.16188 3.53553
% [nap "sd1(m,1)"]
3.93743 4.72264

var(x[,verb_rank])

Variance (with division by n).
% [nap "var(v)"]
23.75
% [nap "var(m)"]
4 13.3225 6.25
% [nap "var(m,1)"]
10.3356 14.8689

var1(x[,verb_rank])

Variance (with division by n-1).
% [nap "var1(v)"]
27.1429
% [nap "var1(m)"]
8 26.645 12.5
% [nap "var1(m,1)"]
15.5033 22.3033

Author: Harvey Davies       © 2002, CSIRO Australia.       Legal Notice and Disclaimer
CVS Version Details: $Id: stat.html,v 1.2 2003/03/17 01:07:45 dav480 Exp $