Live data from Hacker News

Show HN: st – simple statistics from the command line

github.com

1–10 of 28 posts

Re: Show HN: st – simple statistics from the command line

#3
For casual purposes st may be convenient, but it doesn't have state of the art numerical stability:

    my $variance = $count > 1 ? ($sum_square - ($sum**2/$count)) / ($count-1) : undef;
Taking the difference between two similar numbers loses precision, and in extreme cases squaring the raw numbers could cause overflow. For comparison, see the recently posted: http://www.python.org/dev/peps/pep-0450/ and https://en.wikipedia.org/wiki/Algorithms_for_calculating_var...

Re: Show HN: st – simple statistics from the command line

#5
post #2

I'd just use octave. It's as simple as $ octave octave:1> a=load('numbers.txt'); octave:2> sum(a) ans = 55 octave:3> mean(a) ans = 5.5000 octave:4> std(a) ans = 3.0277 octave:5> quantile(a) ans = 1.0000 3.0000 5.5000 8.0000 10.0000 etc

I like octave and R!

The reason I wrote this script was to get quick results from the command line.

For instance: I could use grep, cut and other unix tools to get the numbers from a file and make quick calculations.

Of course, for complex processing I would use octave or R.

Re: Show HN: st – simple statistics from the command line

#6
post #5
post #2

I'd just use octave. It's as simple as $ octave octave:1> a=load('numbers.txt'); octave:2> sum(a) ans = 55 octave:3> mean(a) ans = 5.5000 octave:4> std(a) ans = 3.0277 octave:5> quantile(a) ans = 1.0000 3.0000 5.5000 8.0000 10.0000 etc

I like octave and R! The reason I wrote this script was to get quick results from the command line. For instance: I could use grep, cut and other unix tools to get the numbers from a file and make quick calculations. Of course, for complex processing I would use octave or R.

Yeah, I was thinking about that and spent the past minutes to make me some Bash functions like:

  function mean() {
          octave -q --eval "mean = mean(load('$1'))"
  }
Then just run "mean numbers.txt".

I am sure your approach is much quicker, octave takes a good 0.5s(!) to load on my machine.

Re: Show HN: st – simple statistics from the command line

#7
post #4

suckless' terminal emulator already uses the name st, though it's not quite popular enough to be in any major repos. http://st.suckless.org/

Thanks for the information!

I wanted to use "stat", but it was already used (display file status); "statistics" was too big.

Just as curiosity, I got the idea for this script when I wanted to calculate the sum of some numbers and discovered that the "sum" command was used for another purpose (display file checksums and block counts)!

Re: Show HN: st – simple statistics from the command line

#8
post #2

I'd just use octave. It's as simple as $ octave octave:1> a=load('numbers.txt'); octave:2> sum(a) ans = 55 octave:3> mean(a) ans = 5.5000 octave:4> std(a) ans = 3.0277 octave:5> quantile(a) ans = 1.0000 3.0000 5.5000 8.0000 10.0000 etc

Would you be able to use Octave for reading from stdin?

Re: Show HN: st – simple statistics from the command line

#10
post #3

For casual purposes st may be convenient, but it doesn't have state of the art numerical stability: my $variance = $count > 1 ? ($sum_square - ($sum**2/$count)) / ($count-1) : undef; Taking the difference between two similar numbers loses precision, and in extreme cases squaring the raw numbers could cause overflow. For comparison, see the recently posted: http://www.python.org/dev/peps/pep-0450/ and https://en.wikip…

Thanks! I changed the algorithm to online variance, hope it is more stable:

https://github.com/nferraz/st/commit/d0fb1bf814fc5940c5aae39...

Post reply on HN