calstats.py

This is a simple python code that reads a file of numerical values (single column of numbers) and reports simple statistics for them. If you run it with the "-v" flag, you'll get a verbose output that explains all of the statistics. If you give only the input file name you'll get a simple line of out statistics.

 

% calstats.py -h  
usage: calstats.py [-h] [-v] arg1

positional arguments:
  arg1           input files (column of numbers)

optional arguments:
  -h, --help     show this help message and exit
  -v, --verbose  Verbose responses

 

% cat data_file 
0.9
2.4
3.3
2.7
7.0

% calstats.py data_file  
3.26000 2.03037 0.90000 7.00000 2.700000 5 1.015185
 

Here is another simple example where I use the namelist shell script to generate the input data file. I then run calstats.py on this file. Notice that I use the "-v" flag here and get a more verbose output.

 

% namelist 5 
1
2
3
4
5
% namelist 5 >dat.1 

% calstats.py -v dat.1 
3.00000 1.41421 1.00000 5.00000 3.000000 5 0.707107
(mean,std,min,max,median,Npnts,m.e.)

Simple stats for numbers in: dat.1
Mean                     = 3.00000
Median                   = 3.00000
Standard deviation       = 1.41421
Minimum                  = 1.00000
Maximum                  = 5.00000
Number of values         = 5.00000
Mean error of then mean  = 5.00000




Back to SCO CODES page