home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7496 < prev    next >
Encoding:
Internet Message Format  |  1992-12-17  |  2.1 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!agate!doc.ic.ac.uk!uknet!egh-qc!pete
  2. From: pete@egh-qc.uucp (Pete Phillips)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Statistic routines ?
  5. Keywords: statistic
  6. Message-ID: <BzEnu0.5uA@egh-qc.uucp>
  7. Date: 17 Dec 92 13:22:48 GMT
  8. References: <Bz7qCA.Gy5@cosy.sbg.ac.at>
  9. Organization: Surgical Materials Testing Laboratory
  10. Lines: 51
  11.  
  12. lendl@cosy.sbg.ac.at (Otmar Lendl) writes:
  13.  
  14. >I have to do some statistical analysis of data I gather with
  15. >perl scripts, so it would be convenient to use perl for that
  16. >purpose, too.
  17.  
  18. >Before I start to write my own set of functions (Mean, standard-deviation,
  19. >histograms, ...) I better ask if there are already such beasts.
  20. >I checked the script-archives listed in the FAQs (convex, ohio-state),
  21. >but could not find anything suitable.
  22.  
  23. >Can anyone give me pointers ?
  24.  
  25. Well, why bother to write statistics in perl ?  Why not just interface
  26. your perl routines to Gary Perlmans STAT| package ?
  27.  
  28. I recently did some work where I had various columns of data that
  29. needed basic statistical data.  Here are some code snippets to show
  30. you how I did it (basically I had to read a stack of data and select
  31. only certain columns etc, which was pretty ugly, so I've included just
  32. what you need - if you want the rest of the code, mail me):
  33.  
  34. # do statistics
  35. sub statistics {
  36.     foreach $elem (2..25) {     # for each column from 2-25
  37.         @st=eval "\@d$elem";
  38.         $stats=`echo @st | stats mean sd skew kurt`;
  39.         ($mean[$elem],$sd[$elem],$skew[$elem],$kurt[$elem])=split(' ',$stats);
  40.     }
  41. }
  42.  
  43.  
  44.  
  45. # print statistics
  46. sub print_statistics {
  47.     print "=\n";
  48.     foreach $stat_test ("mean","sd","skew","kurt") { # mean, sd, kurt & skew
  49.         print "$stat_test";
  50.         foreach $elem (2..25) {
  51.             printf (":%4.2f",eval "\$$stat_test[\$elem]");
  52.         }
  53.         print "\n";
  54.         
  55.     }
  56.     
  57. }
  58. -- 
  59. Pete Phillips, Surgical Materials Testing Lab, Bridgend, S. Wales.
  60. UUCP   :  uknet!egh-qc!pete            DOMAIN :  pete@egh-qc.co.uk
  61. -----------------------------------------------------------------
  62. "SCIENCE: A way of finding things out and then making them work.  
  63.