File: statistical-analysis.pl

package info (click to toggle)
freecell-solver 3.26.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 4,864 kB
  • ctags: 3,658
  • sloc: ansic: 34,721; perl: 12,320; xml: 5,999; python: 1,149; sh: 965; ruby: 347; cpp: 304; makefile: 151
file content (37 lines) | stat: -rw-r--r-- 740 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl

use strict;
use warnings;

use Statistics::Descriptive;

my $num_fields = 2;

my @stats =
    (map
        { Statistics::Descriptive::Full->new(); }
        (1 .. $num_fields)
    );

while(my $line = <ARGV>)
{
    chomp($line);
    my @vals = split(/\t/, $line);
    foreach my $f (0 .. $num_fields-1)
    {
        $stats[$f]->add_data($vals[$f]);
    }
}

foreach my $f (0 .. $num_fields-1)
{
    my $s = $stats[$f];
    print "Field No. $f\n";
    print "---------------------------\n";
    print "Min: " , $s->min(), "\n";
    print "Max: " , $s->max(), "\n";
    print "Average: " , $s->mean(), "\n";
    print "StdDev: " , $s->standard_deviation(), "\n";
    print "Median: " , $s->median(), "\n";
    print "\n";
}