Perl 的统计学模块名字叫:Statistics
::Descriptive
下载:
$ emerge dev-perl/Statistics-Descriptive
有一个这方面的pdf教程,名叫: Journal of Statistical Software,作者:Giovanni Baiocchi
,杜伦大学
程序示例,计算方差,网上抄的:
- #!/usr/bin/perl
-
-
use strict;
-
use Statistics::Descriptive;
-
-
open(FH, "$ARGV[0]") or die "No file specified\n";
-
my @temp=<FH>;
-
close FH;
-
-
my $stat = Statistics::Descriptive::Full->new();
-
$stat->add_data(\@temp);
-
my $mean = $stat->mean();
-
my $variance = $stat->variance();
-
my $num = $stat->count();
-
-
print "Number of Values = $num\n",
-
"Mean = $mean\n",
-
"Variance = $variance\n";
阅读(3101) | 评论(0) | 转发(0) |