统计

From Yefu's notes
Jump to: navigation, search
#!/usr/bin/perl

use Statistics::Descriptive;

open F, $ARGV[0];

$line=<F>;
my @data=split(' ', $line);

for my $i(0..$#data)
{
 $stat[$i] = Statistics::Descriptive::Full->new();
 $stat[$i]->add_data($data[$i]);
}

while (<F>)
{
 chomp;
 @data=split(' ',$_);
 for my $i(0..$#data)
 {
  $stat[$i]->add_data($data[$i]);
 }
}

 for my $i(0..$#data)
 {
  print $stat[$i]->mean() ;
  print " ";
 }
print "\n";

 for my $i(0..$#data)
 {
  print $stat[$i]->standard_deviation() ;
  print " ";
 }
print "\n";

<comments/>