Show HN: st – simple statistics from the command line
1–10 of 28 posts
Re: Show HN: st – simple statistics from the command line
#2 $ 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
etcRe: Show HN: st – simple statistics from the command line
#3 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
#4Re: Show HN: st – simple statistics from the command line
#5I'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
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
#6I'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.
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
#7suckless' terminal emulator already uses the name st, though it's not quite popular enough to be in any major repos. http://st.suckless.org/
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
#8I'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
Re: Show HN: st – simple statistics from the command line
#9Re: Show HN: st – simple statistics from the command line
#10For 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…
https://github.com/nferraz/st/commit/d0fb1bf814fc5940c5aae39...