Live data from Hacker News

Show HN: st – simple statistics from the command line

github.com

21–28 of 28 posts

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

#21
post #14
post #8

Earlier quoted context omitted.

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

Yes, Sprint suggested this: octave -q --eval "mean = mean(load('$1'))" But, again, octave requires more time to warm up...

That does not read the data from stdin. You could probably get it to work with some bash wizardry. But maybe not. I did spend some time on this a few years ago and it may have changed in the interim, but my memory is that I tried load("/dev/stdin") and using a fifo etc and it doesn't work (probably because load() uses some seeks to determine matrix data shape before reading data in i.e. data is read in as columns instead of reading in rows and transposing). At least that was my takeaway. At least if you want to use the load() builtin.

Basically you just need to write an octave function that reads values from the terminal.

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

#22
Lovely! As someone with my own little script to sum up the values in a given column, I can see how you'd want to just have this tool sitting ready to hand in ~/bin in wherever. And this script seems to adhere better to the Unix way than mine, since it's easy to use cut(1) to extract whatever column you want, but it makes sense for one tool to do sum, mean, sd, etc. Thanks for sharing!

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

#23
One suggestion: whatever the default may be, give an option to have line-delimited output rather than column-delimited.

IMHO if you want your script's output to be easily usable by other scripts, line-delimited is easier since you can grep out what lines you want rather than having to rely on the column position never changing (since you can give cut only a field number and not a field name like "average").

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

#24
So, http://suso.suso.org/programs/num-utils/index.phtml already exists and is written in perl. It seems like your major contribution is a statistical slant, which might be compatible with the existing code base.

edit: it's perl, not python. brainfart on my part.

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

#27
why not write a one line python program instead? I'd never use the shell for these kinds of things. Quickly they grow into more than something that a simple one liner can handle. Before you know it, you're reading from a CSV and summing column "foo" and so on. This then turns your shell approach into mess, instead of a (now 5 line) python program.

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

#28

maybe you are not aware of it, but there is a nifty little tool in freebsd called ministat that somewhat overlaps with what you did, maybe of interest: http://www.freebsd.org/cgi/man.cgi?query=ministat&apropos=0&...

EXACTLY!

I converted this tool to linux for the archlinux package forever ago:

https://github.com/codemac/ministat

There are a few forks (adding autoconf, an osx branch, etc) as well.

Post reply on HN