【perl】统计学模块

3207阅读 0评论2011-08-26 mystérieux
分类:Python/Ruby

Perl 的统计学模块名字叫:Statistics::Descriptive
下载:
$ emerge dev-perl/Statistics-Descriptive
有一个这方面的pdf教程,名叫: Journal of Statistical Software,作者:Giovanni Baiocchi,杜伦大学
程序示例,计算方差,网上抄的:
  1. #!/usr/bin/perl

  2. use strict;
  3. use Statistics::Descriptive;

  4. open(FH, "$ARGV[0]") or die "No file specified\n";
  5. my @temp=<FH>;
  6. close FH;

  7. my $stat = Statistics::Descriptive::Full->new();
  8. $stat->add_data(\@temp);
  9. my $mean = $stat->mean();
  10. my $variance = $stat->variance();
  11. my $num = $stat->count();

  12. print "Number of Values = $num\n",
  13.       "Mean = $mean\n",
  14.       "Variance = $variance\n";

上一篇:博客已升级,请注意变更地址
下一篇:提一下 realplayer