stat
PURPOSE
Provides tools for analyzing numerical data.
DESCRIPTION
The stat commands, residing in /usr/bin/graf, provide a
package of tools for analyzing data. All numerical data
are stored in vectors. A vector is a sequence of numbers
separated by delimiters, where a number has the form:
[sign](digits)(.digits)[e[sign]digits]
Fields surrounded by brackets are optional; one or both
of those surrounded by parentheses are required. Any
input character that is not part of a number is assumed
to be a delimiter.
Vectors are text strings that can be stored in text files
and created and modified by text editors.
Note: Some commands limit the size of an input vector.
These commands can be divided into four classes:
o Those that produce an output vector based upon defin-
able parameters (generators).
o Those that operate upon an input vector and output
the resulting value (transformers).
o Those that perform mathematical or statistical oper-
ations on vectors (summarizers).
o Those that convert vectors into a format that can be
viewed pictorially (translators).
The following parameters are used to designate the
expected type of the value:
c A character value.
i An integer value.
f A floating-point or integer value.
file A file name.
vector A vector taken from standard input or the name of
a file containing a vector. Except for the gas,
prime, and rand commands, all of the commands dis-
cussed under stat read vectors from standard input
(by default) or from text files as specified on the
command line. A file name of - (minus) specifies
standard input in a file list.
string A character string (quoted if it includes white
space).
COMMANDS THAT PRODUCE DEFINABLE VECTORS (GENERATORS)
gas
SYNTAX
gas [-ci,if,ni,sf,tf]
DESCRIPTION The gas command produces an additive
sequence.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-if Specifies the increment between successive elements
(1 by default).
-ni Specifies the number of elements in the vector (10
by default).
-sf Specifies the starting point of the sequence (1 by
default).
-tf Specifies the end of the sequence (infinity by
default).
EXAMPLES
1. To generate the numbers 1 through 10:
gas
2. To generate the sequence ".01 .02 .03 .04 .05":
gas -s.01,t.05,i.01
3. To generate the sequence "3 5 3 5":
gas -s3,t5,i2,n4
prime
SYNTAX
prime [-ci,hi,li,ni]
DESCRIPTION: The prime command generates consecutive
prime numbers.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-hi Specifies the high boundary (infinity by default).
-li Specifies the low boundary (2 by default).
-ni Specifies the number of elements in the sequence (10
by default).
EXAMPLE: To generate all prime numbers between 200 and
300:
prime -l200,-h300
rand
SYNTAX
rand [-ci,hf,lf,mf,ni si]
DESCRIPTION: The rand command generates a random
sequence of numbers.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-hf Specifies the high boundary (1 by default).
-lf Specifies the low boundary (0 by default).
-ni Specifies the number of elements in the sequence (10
by default).
-si Specifies a seed number (1 by default).
EXAMPLE: To produce a random sequence:
rand
This generates ten random numbers between 0 and 1.
rand -l10,m25,c3
The generates ten random numbers between 10 and 35, three
per line.
COMMANDS THAT MAP INPUT TO OUTPUT (TRANSFORMERS)
abs
SYNTAX
abs [-ci] [vector . . . ]
DESCRIPTION: The abs command provides the absolute value
of a number.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
EXAMPLE: To obtain the absolute value of each element in
a vector:
abs -c3 myfile
This produces the absolute value of each number in the
file "myfile" and displays these values three per line.
af
SYNTAX
af [-ci,t,v] expression . . .
DESCRIPTION: The af command performs arithmetic oper-
ations on numbers.
EXPRESSIONS: Expression operands are:
Vectors File names with the restriction that they must
begin with a letter and be composed only of
letters, digits, and the _ (underscore) and .
(dot) characters. The first unknown file name
(one not in the current directory) references
standard input.
Functions The name of a command followed by the command
arguments in parentheses. List arguments as
you would on the command line.
Constants Floating-point and integer numbers (but not E
notation).
Expression operators are, in order of decreasing preced-
ence:
'v The next value from vector v.
x^y -x The value x raised to the power y; the negation
of x. Both associate right to left.
x*y x/y x%y The value x multiplied by, divided by,
modulo y, respectively. All associate left to
right.
x+y x-y The value x plus or minus y. Both associate
left to right.
x,y The value of x followed by the value of y. This
associates from left to right.
You can use parentheses to alter precedence. Because
many of the operator characters are special to the shell,
it is good practice to quote expression arguments.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-t Cause the output to be titled from the vector on
standard input.
-v Echoes function expansions.
EXAMPLES
1. To perform arithmetic operations:
af "3+4*5"
This yields "23".
2. To produce a matrix:
af "A,'A,A+'A,B"
This yields a four-column matrix with columns of:
a. odd elements from vector "A"
b. even elements from "A"
c. sum of adjacent odd and even elements from "A"
d. elements from vector "B".
3. To use functions:
af "sin (A)^2"
This yields the square of the sin of the elements of
vector "A".
ceil
SYNTAX
ceil [-ci] [vector . . . ]
DESCRIPTION: The ceil command rounds a number up to the
next integer.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
cusum
SYNTAX
cusum [-ci] [vector . . . ]
DESCRIPTION: The cusum command calculates a cumulative
sum. Output is a vector with the ith element being the
sum of the first i elements from the input vector.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
exp
SYNTAX
exp [-ci] [vector . . . ]
DESCRIPTION: The exp command provides the exponential
function. Output is a vector with elements e raised to
the x power, where e is approximately 2.71828 and x is
each element in the input vector.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
floor
SYNTAX
floor [-ci] [vector . . . ]
DESCRIPTION: The floor command rounds a number down to
the nearest integer.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
gamma
SYNTAX
gamma [-ci] [vector . . . ]
DESCRIPTION: The gamma command provides the gamma func-
tion.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
list
SYNTAX
list [-ci,dstring [ file . . . ]
DESCRIPTION: The list command lists vector elements.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-dstring Specifies delimiters characters. If you do not
specify -d, any character that is not part of a
number is considered a delimiter. If you specify
-d, the space, tab, and new-line characters, plus
the characters in string are delimiters.
Only numbers surrounded by delimiters are listed.
EXAMPLES
1. To output each element:
list -c3 myfile
This outputs each element in "myfile", three per
line.
2. To specify delimiters:
list -d\\, myfile
This outputs each element of "myfile" that is delim-
ited by commas or white space, five per line. A
comma requires two backslashes because it is a
special character for list.
log
SYNTAX
log [-ci,-bf] [vector . . . ]
DESCRIPTION: The log command provides the logarithmic
function.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
-bf Specifies the base (e by default).
EXAMPLE: To calculate a logarithm:
log -b2,c3 mydata
This outputs the logarithm base 2 of each element in
"mydata", three per line.
mod
SYNTAX
mod [-ci mf] [vector . . . ]
DESCRIPTION: The mod command returns the modulo. The
output is a vector with each element being the remainder
of dividing the corresponding element from the input
vector by the modulus.
-ci Specifies the number of columns per line of output
(5 by default).
-mf Specifies the modulus (2 by default).
EXAMPLE: To output remainders:
mod -m8,c3 mydata
This outputs the elements of "mydata" modulo "8", three
per line.
pair
SYNTAX
pair [-ci,Ffile,xi] [vector . . . ]
DESCRIPTION: The pair command pairs elements. Output is
a vector with elements taken alternatively from a base
vector and from another input vector.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-Ffile The file containing the base vector. If you do
not specify -F, then the base vector comes from
standard input. If both the base vector and the
paired vector come from standard input, the base
vector precedes the paired vector.
-xi The number of elements per group in the base vector
(1 by default).
EXAMPLE: To pair elements:
pair -x3,Fbasefile datafile
This outputs a vector with three elements from
"basefile", one from "datafile", three from "basefile",
one from "datafile", and so on.
power
SYNTAX
power [-ci,pf] [vector . . . ]
DESCRIPTION: The power command raises a number to a
power.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
-pf Specifies the power (2 by default).
root
SYNTAX
root [-ci,rf] [vector . . . ]
DESCRIPTION: The root command takes the root of a
number.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-rf Specifies the root (2 by default).
round
SYNTAX
round [-ci,pi,si] [vector . . . ]
DESCRIPTION: The round command rounds a number to the
nearest integer (.5 rounds to 1).
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-pi Specifies the number of places after the decimal
point (0 by default).
-si Specifies the number of significant digits.
EXAMPLE: To round numbers to two significant digits:
round -s2,c3 mydata
siline
SYNTAX
siline [-ci,if,ni,sf] [vector . . . ]
DESCRIPTION: The siline command generates a line, given
slope and intercept.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
-if Specifies the intercept (0 by default).
-ni Specifies the number of positive integers.
-sf Specifies the slope of the line.
EXAMPLE: To output a linear fit:
siline -`lref -o,FA B` A
This outputs a simple linear fit of vector "B" on vector
"A" (The o flag of lreg outputs the slope and intercept
in option form of "B" regressed on "A".)
sin
SYNTAX
sin [-ci] [vector . . . ]
DESCRIPTION: The sin command provides the sine function.
FLAGS
-ci Specifies the number of columns per line of output
(5 by default).
subset
SYNTAX
subset [-af,bf,ci,Ffile,ii,lf,nl,np,pf,si,ti] [vector . . . ]
DESCRIPTION: The subset command produces a subset of the
numbers in a vector.
FLAGS
-af Specifies the number above which subset members are
selected.
-bf Specifies the number below which subset members are
selected.
-ci Specifies the number of columns per line of output
(5 by default).
-Ffile Specifies the file containing the master vector.
-ii Specifies the increment between successive elements
(1 by default).
-lf The number of elements to leave.
-nli Specifies that the master file contains element
numbers to leave.
-npi Specifies that the master file contains element
numbers to pick.
-pf The number of elements to pick.
-sf Specifies the starting point of the sequence (1 by
default).
-tf Specifies the end of the sequence (32,767 by
default).
EXAMPLES
1. To specify the even elements of a vector:
subset -i2,s2 myfile
2. To specify corresponding elements:
subset -FB,p1 A
For each element in "B" with a "1", output the corre-
sponding element in "A".
COMMANDS THAT CALCULATE STATISTICS (SUMMARIZERS)
bucket
SYNTAX
bucket [-ai,ci,Ffile,hf,ii,lf,ni] [vector . . . ]
DESCRIPTION: The bucket command groups numbers into
buckets. The input vector must be sorted. The output
vector consists of odd (parenthesized) elements that are
bucket limits and even elements that are bucket counts.
The count is the number of elements greater than or equal
to the lowest limit and less than or equal to the higher
limit. Unless otherwise specified, bucket limits are
generated based on the input date and the following rule:
#buckets = 1 + log2(#elements)
FLAGS
-ai Specifies the average size of the bucket.
-ci Specifies the number of columns per line of output
(5 by default).
-Ffile Specifies the file containing bucket boundaries.
-hf Specifies the high boundary (by default, the largest
element in the input vector).
-ii Specifies the interval between successive elements.
-li Specifies the low boundary (by default, the smallest
element in the input vector).
-ni Specifies the number of buckets.
EXAMPLE: To divide elements into buckets:
bucket -a12,l-5 myfile
This outputs limits and counts for the elements of
"myfile", where the lowest limit is "-5" and the average
bucket count is "12".
cor
SYNTAX
cor [-Ffile] [vector . . . ]
DESCRIPTION: The cor command provides the ordinary cor-
relation coefficient. Use the F flag to specify the base
vector; otherwise it is assumed to come from standard
input. Each vector is compared to the base vector (both
must be of the same length).
FLAG
-Ffile Specifies the file containing base vector.
EXAMPLE: To obtain correlation coefficients:
cor -Ffilea olddata newdata
This outputs the ordinary correlation coefficients
between vectors "filea" and "olddata" and vectors "filea"
and "newdata".
hilo
hilo [-h,l,o,ox,oy] [vector . . . ]
DESCRIPTION: The hilo command finds high and low values
across all of the input vectors.
-h Finds the high value only.
-l Finds the low value only.
-o Outputs the high and low values in option form
(suitable for plot).
-ox Outputs the high and low values in option form with
x prefixed.
-oy Outputs the high and low values in option form with
y prefixed.
EXAMPLE: To find the lowest value:
hilo -ox,l file1 file2
This finds the lowest value in vectors "file1" and
"file2" and outputs it with "xl" prefixed to it.
lreg
SYNTAX
lreg [-Ffile,i,o,s] [vector . . . ]
DESCRIPTION: The lreg command provides linear
regression. Output is the slope and intercept from a
least squares linear regression of each vector on a base
vector. The default base vector is the ascending posi-
tive integers from zero.
FLAGS
-Ffile Specifies a file containing the first vector.
-i Outputs only the intercept.
-o Outputs the slope and intercepts in option form
(suitable for siline).
-s Outputs only the slope.
EXAMPLE: To output only the intercept:
lreg -Fbase,i mydata
This outputs the intercept from the linear regression of
vector "mydata" on base vector "base".
mean
SYNTAX
mean [-ff,ni,pf]
DESCRIPTION: The mean command calculates the (trimmed)
arithmetic mean.
FLAGS
-ff Specifies the fraction of elements to trim from each
end. This is calculated as follows:
(1/f) k
where k is the total number of elements.
-ni Specifies the number of elements to trim from each
end.
-pf Specifies the percentage of elements to trim from
each end.
EXAMPLE: To output the mean:
mean -p.25 mydata
This outputs the mean of the middle 50% of the elements
of "mydata"; that is, "mydata" is trimmed by 25% of its
elements from both ends.
point
SYNTAX
point [-ff,ni,pf,s] [vector . . . ]
DESCRIPTION: Output from the point command is a linearly
interpolated value from the empirical cumulative density
function for the input vector. By default, point returns
the median (50% point).
FLAGS
-ff Returns the (1/f)*100 percent point.
-ni Returns the ith element.
-pf Returns the f*100 percent point.
-s Specifies that the input has been sorted.
EXAMPLE: To output the 25% point:
point -s,p.25 mydata
prod
SYNTAX
prod
DESCRIPTION: The prod commands calculates an internal
product. Output is the product of the elements in the
input vectors.
qsort
SYNTAX
qsort [-ci] [vector . . . ]
DESCRIPTION: The qsort command does a quick sort.
Output is a vector of the elements from the input vector
in ascending order.
FLAG
-ci Specifies the number of columns per line of output
(5 by default).
rank
SYNTAX
rank [vector . . . ]
DESCRIPTION: The rank command ranks vectors. Output is
the number of elements in each input vector.
total
SYNTAX
total [vector . . . ]
DESCRIPTION: The total command calculates a sum total.
Output is the sum total of the elements in the input
vector(s).
var
SYNTAX
var [vector . . . ]
DESCRIPTION: The var command calculates the variance.
COMMANDS THAT PRODUCE PICTORIAL OUTPUT (TRANSLATORS)
Input to these commands can be either a vector or a gps
object (a format for storing a picture). A picture is
defined in a Cartesian plane of 64K points on each axis.
The plane, or universe, is divided into 25 square regions
numbered 1 to 25 from the lower left to the upper right.
bar
SYNTAX
bar [-a,b,f,g,ri,wi,xf,xa,yf,ya,ylf,yhf] [vector . . . ]
DESCRIPTION: The bar command builds a bar chart. It
operates on an input vector, each element of which
defines the height of a bar (y-axis). By default, the
x-axis is labeled with positive integers, beginning at 1.
For other labels, see label.
FLAGS
-a Suppresses the axes.
-b Plots the bar chart with bold weight lines (medium
is the default weight).
-f Does not build a frame around the plot area.
-g Suppresses the background grid.
-ri Puts the bar chart in gps region i, where i is
between 1 and 25 inclusive (13 by default).
-wi Specifies the ratio of the bar width to center-to-
center spacing expressed as a percentage (50 by
default, giving equal bar width and bar space).
-xf
-yf Positions the bar chart in the gps universe with the
x-origin (y-origin) at f.
-xa
-ya Does not label the x-axis (y-axis).
-yhf Specifies the y-axis high boundary.
-ylf Specifies the y-axis low boundary.
EXAMPLE: To produce a bar chart:
bar -r10,xa,w75 myfile
This outputs the bar chart described by vector "myfile",
located in region "10" of the gps universe, with no
x-axis labels. The bar width is 75% of center-to-center
spacing.
hist
SYNTAX
hist [-a,b,f,g,ri,xf,xa,yf,ya,ylf,yhf] [vector . . .
DESCRIPTION: The hist command builds a histogram. The
input vector is the type produced by bucket, of odd rank,
with odd elements being limits and even elements being
bucket counts.
FLAGS
-a Suppresses axes.
-b Plots histogram with bold weight lines (the default
weight is medium).
-f Does not build a frame around the plot area.
-g Suppresses the background grid.
-ri Puts the histogram in gps region i, where i is
between 1 and 25 inclusive (13 by default).
-xf
-yf Positions the histogram in the gps universe with the
x-origin (y-origin) at f.
-xa
-ya Does not label the x-axis (y-axis).
-yhf Specifies the y-axis high boundary.
-ylf Specifies the y-axis low boundary.
EXAMPLE: To produce a histogram:
hist -r5,ya myfile
This outputs the histogram described by vector "myfile"
and locates it in region 5 of the gps universe, with no
y-axis labels.
label
SYNTAX
label [-b,c,Ffile,h,p,ri,x,xu,y,yr] [GPSfile . . . ]
DESCRIPTION: The label command labels the axis of a gps
file.
FLAGS
-b Assumes that the input is a bar chart.
-c Retains lowercase letters in labels; otherwise all
letters are uppercase.
-Ffile Specifies a label file. Each line of the file is
taken as one label. Blank lines yield null labels.
Either the gps or the label file, but not both, can
come from standard input.
-h Assumes that the input is a histogram.
-p Assumes that the input is an x-y plot. This is the
default assumption.
-ri Rotates labels i degrees. The pivot point is the
first character.
-x Labels the x-axis. This is the default action.
-xu Labels the upper x-axis (the top of the plot).
-y Labels the y-axis.
-yr Labels the right y-axis (the right side of the
plot).
EXAMPLES
1. To label a plot:
label -Flabs A.g
The file "A.g", assumed to be an x-y plot, is labeled
with labels from the file "labs".
2. To label a plot from labels taken from standard
input:
label -yr,r-45 A.g
The file "A.g" is labeled from the standard input.
The labels are printed at 45 degrees below the hori-
zontal.
pie
SYNTAX
pie [-b,o,p,pni,ppi,ri,v,xi,yi] [vector . . . ]
DESCRIPTION: The pie command builds a pie chart. The
input vector has a restricted format. Each input line
represents a slice of the pies and has the following
form:
[<i e f ccolor>] value [label]
with brackets indicating optional fields. The control
field options have the following effects:
i The slice will not be drawn, though a space will
be left for it.
e The slice is "exploded" or moved away from the
pie.
f The slice is filled. The angle of fill lines
depends on the color of the slice.
ccolor The slice is drawn in the specified color rather
than the default black. Legal values are b
(black), r (red), g (green), and u (blue).
The pie is drawn with the value of each slice printed
inside and the label printed outside.
FLAGS
-b Draws pie chart with bold weight lines (the default
weight is medium).
-o Places output values around the outside of the pie.
-p Expresses output values as a percentage of the total
pie.
-pni Expresses output values as a percentage, but the
total of the percentages equals i rather than 100.
-ppi Draws only i percent of the pie.
-ri Puts the pie chart in gps region i, where i is
between 1 and 25 inclusive (13 by default).
-v Does not output values.
-xi
-yi Positions the pie chart in the gps universe with
x-origin (y-origin) at i.
EXAMPLE: To draw a pie chart:
pie -pp80,pn80 chartfile
This draws the pie chart specified by "chartfile" in 80%
of a circle and outputs the values as percentages of that
total 80 percent.
plot
SYNTAX
plot [-a,b,cstring,d,f,Ffile,g,m,ri,xf,xa,xif,xhf,xlf,xni,xt,yf,ya,yif,yhf,ylf,yni,yt] [vector . . . ]
DESCRIPTION: The plot command plots a graph. The input
vectors contain the y values of an x-y graph. Values for
the x-axis come from the file specified by -F. Axis
scales are determined from the first vector plotted.
FLAGS
-a Suppresses the axes.
-b Plots the graph with bold weight lines (medium is
the default weight).
-d Does not connect plotted points (this implies -m).
-f Does not build a frame around the plot area.
-Ffile Uses the specified file for x values; otherwise
the positive integers are used. You can specify
this flag more than once, causing a different set of
x values to be paired with each input vector. If
there are more input vectors than sets of x values,
the last set applies to the remaining vectors.
-g Suppresses the background grid.
-m Marks the plotted points.
-ri Puts the graph in gps region i, where i is between 1
and 25 inclusive (13 by default).
-xf
-yf Positions the graph in the gps universe with the
x-origin (y-origin) at f.
-xa
-ya Does not label the x-axis (y-axis).
-xa
-ya Does not label the x-axis (y-axis).
-xhf
-yhf Specifies the x-axis (y-axis) high boundary.
-xlf
-ylf Specifies the x-axis (y-axis) low boundary.
-xni
-yni Specifies the approximate number of ticks on the
x-axis (y-axis).
-xt
-yt Omits the x-axis (y-axis) title.
EXAMPLES
1. To plot against the positive integers:
plot plotdata
2. To customize x- and y-axes:
plot -r5,y10,xa,Fxfile yfile
This plots vector "yfile" against vector "xfile",
with y-axis ticks beginning at zero, no x-axis labels
being printed, and the plot being placed in region 5
of the gps universe.
plot -`hilo -oy filea fileb` filea fileb
This plots vectors "filea" and "fileb" against the
positive integers, with y-axis ticks going from the
lowest to the highest values in the two vectors.
plot -Ffilea,Ffileb filec filed filee
This plots vectors "filec" against "filea"; "filed"
and "filee" against "fileb". The y-axis scale is
determined from "filec"; the x-axis scale from
"filea".
title
SYNTAX
title [-b,c,lstring,vstring,ustring] [vector . . . ]
DESCRIPTION: The title command prefixes a title to a
vector or appends one to a GPS object.
FLAGS
-b Makes the gps title bold.
-c Retains lowercase letters in the title; otherwise
all letters are uppercase.
-lstring Uses the specified string as a gps lower title.
-ustring Uses the specified string as a gps upper title.
-vstring Labels a vector with the specified string.
RELATED INFORMATION
The following commands: "ged," "graphics," and
"spline."
The gps file in AIX Operating System Technical Reference.