трещина костяшек
используя модуль Statistics::Descriptive
CPAN, вы можете получить его следующим образом:
use strict;
use warnings;
use Statistics::Descriptive;
my ($file) = @ARGV;
my @zeroes;
my @ones;
# Reading it in
open my $fh, '<', $file or die "unable to open '$file', $!";
while (my $line = <$fh>)
{
chomp $line;
my ($value, $number) = split("\s+", $line);
if ($value)
{
push @ones, $number;
}
else
{
push @zeroes, $number;
}
}
close $fh or warn "Can't close fh! $!";
# Stat processing
$stat_zeroes = Statistics::Descriptive::Full->new();
$stat_ones = Statistics::Descriptive::Full->new();
$stat_zeroes->add_data(@zeroes);
$stat_ones->add_data(@ones);
print "0: ", $stat_zeroes->mean(), " ", $stat_zeroes->standard_deviation(), "\n",
"1: ", $stat_ones->mean(), " ", $stat_zeroes->standard_deviation(), "\n";