home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!doc.ic.ac.uk!uknet!egh-qc!pete
- From: pete@egh-qc.uucp (Pete Phillips)
- Newsgroups: comp.lang.perl
- Subject: Re: Statistic routines ?
- Keywords: statistic
- Message-ID: <BzEnu0.5uA@egh-qc.uucp>
- Date: 17 Dec 92 13:22:48 GMT
- References: <Bz7qCA.Gy5@cosy.sbg.ac.at>
- Organization: Surgical Materials Testing Laboratory
- Lines: 51
-
- lendl@cosy.sbg.ac.at (Otmar Lendl) writes:
-
- >I have to do some statistical analysis of data I gather with
- >perl scripts, so it would be convenient to use perl for that
- >purpose, too.
-
- >Before I start to write my own set of functions (Mean, standard-deviation,
- >histograms, ...) I better ask if there are already such beasts.
- >I checked the script-archives listed in the FAQs (convex, ohio-state),
- >but could not find anything suitable.
-
- >Can anyone give me pointers ?
-
- Well, why bother to write statistics in perl ? Why not just interface
- your perl routines to Gary Perlmans STAT| package ?
-
- I recently did some work where I had various columns of data that
- needed basic statistical data. Here are some code snippets to show
- you how I did it (basically I had to read a stack of data and select
- only certain columns etc, which was pretty ugly, so I've included just
- what you need - if you want the rest of the code, mail me):
-
- # do statistics
- sub statistics {
- foreach $elem (2..25) { # for each column from 2-25
- @st=eval "\@d$elem";
- $stats=`echo @st | stats mean sd skew kurt`;
- ($mean[$elem],$sd[$elem],$skew[$elem],$kurt[$elem])=split(' ',$stats);
- }
- }
-
-
-
- # print statistics
- sub print_statistics {
- print "=\n";
- foreach $stat_test ("mean","sd","skew","kurt") { # mean, sd, kurt & skew
- print "$stat_test";
- foreach $elem (2..25) {
- printf (":%4.2f",eval "\$$stat_test[\$elem]");
- }
- print "\n";
-
- }
-
- }
- --
- Pete Phillips, Surgical Materials Testing Lab, Bridgend, S. Wales.
- UUCP : uknet!egh-qc!pete DOMAIN : pete@egh-qc.co.uk
- -----------------------------------------------------------------
- "SCIENCE: A way of finding things out and then making them work.
-