Giter Site home page Giter Site logo

st's Introduction

st

simple statistics from the command line interface (CLI)

Description

Imagine you have this sample file:

$ cat numbers.txt
1
2
3
4
5
6
7
8
9
10

How do you calculate the sum of the numbers?

The traditional way

If you ask around, you'll come up with suggestions like these:

$ awk '{s+=$1} END {print s}' numbers.txt
55

$ perl -lne '$x += $_; END { print $x; }' numbers.txt
55

$ sum=0; while read num ; do sum=$(($sum + $num)); done < numbers.txt ; echo $sum
55

$ paste -sd+ numbers.txt | bc
55

Now imagine that you need to calculate the arithmetic mean, median, or standard deviation...

Using st

"st" is a command-line tool to calculate simple statistics from a file or standard input.

Let's start with "sum":

$ st --sum numbers.txt
55

That was easy!

How about mean and standard deviation?

$ st --mean --stddev numbers.txt
mean  stddev
5.5   3.02765

If you don't specify any options, you'll get this output:

$ st numbers.txt
N     min   max   sum   mean  stddev
10    1     10    55    5.5   3.02765

You can switch rows and columns using the "--transpose-output" option:

$ st --transpose-output numbers.txt
N       10
min     1
max     10
sum     55
mean    5.5
stddev  3.02765

The "--summary" option will provide the five-number summary:

$ st --summary numbers.txt
min   q1    median  q3    max
1     3.5   5.5     7.5   10

And "--complete" will print a complete description:

$ st --complete numbers.txt
N   min   q1    median  q3    max   sum   mean  stddev  stderr
10  1     3.5   5.5     7.5   10    55    5.5   3.02765 0.957427

How does it compare with R, Octave and other analytical tools?

"R" and Octave are integrated suites for data manipulation, calculation and graphical display.

They provide high-level interpreted languages, capabilities for the numerical solution of linear and nonlinear problems, and for performing other numerical experiments, including statistical tests, classification, clustering, etc.

"st" is a simpler solution for simpler problems, focused on descriptive statistics for small datasets, handy when you need quick results without leaving the shell.

Usage

st [options] [file]

Options

Functions
--N|n|count
--mean|avg|m
--stddev|sd
--stderr|sem|se
--sum|s
--var|variance

--min
--q1
--median
--q3
--max

--percentile=<0..1>
--quartile=<1..4>

If no functions are selected, "st" will print the default output:

N     min  max  sum  mean  stddev

You can also use the following predefined sets of functions:

--summary   # five-number summary (min q1 median q3 max)
--complete  # everything
Formatting
--format|fmt|f=<value>  # default: "%g"
--delimiter|d=<value>   # default: "\t"

--no-header|nh          # don't display header
--transpose-output|to   # switch rows and columns

Examples of valid formats ("--format" option):

    %d    signed integer, in decimal
    %e    floating-point number, in scientific notation
    %f    floating-point number, in fixed decimal notation
    %g    floating-point number, in %e or %f notation
Input validation

By default, "st" skips invalid input with a warning.

You can change this behavior with the following options:

--strict   # throws an error, interrupting process
--quiet|q  # no warning

Author

Nelson Ferraz <[email protected]>

Contribute

Send comments, suggestions and bug reports to:

https://github.com/nferraz/st/issues

Or fork the code on github:

https://github.com/nferraz/st

st's People

Contributors

nferraz avatar nelson-ferraz avatar gabeguz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.