Computing basic statistics for the UNIX command line

This page details a simple C++ program I wrote to compute some basic statistics for UNIX/Linux command line interface workflows.

Example usage

I was just working with correlations and wanted to see that my algorithms indeed computed values between -1 and 1 and I was expecting a mean of about 0. So using my range program, I can check these simple statistics as follows:

$ ./computecorrelations.rb | range N 1264632 sum 9717.46 min -0.996154 max 0.99789 mean 0.00768402 var 0.119903 stddev 0.34627

Excellent.

The range program takes a list of values from standard in and computes the statistics (number of elements N, sum of the elements, their minimum and maximum, its mean, variance and standard deviations) and outputs them.

$ echo "1 2 3" | range N 3 sum 6 min 1 max 3 mean 2 var 1 stddev 1

Source

You can download the source from http://anthony.liekens.net/pub/range.cpp and compile it with

g++ -O3 range.cpp -o range

and put it somewhere interestingly, like

sudo cp range /usr/local/bin/


comments powered by Disqus