crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

xr-analyze-test (428B)


      1 #!/usr/bin/perl
      2 
      3 use strict;
      4 
      5 my $n = 0;
      6 my $tot = 0;
      7 my @num;
      8 while (my $line = <STDIN>) {
      9     next unless ($line =~ /^\d/);
     10     $tot += $line;
     11     push(@num, $line);
     12     $n++;
     13 }
     14 exit(1) if ($n < 2);
     15 
     16 my $avg = $tot / $n;
     17 my $sumsq = 0;
     18 for my $n (@num) {
     19     my $diff = $n - $avg;
     20     $sumsq += ($diff * $diff);
     21 }
     22 
     23 print ("Total   : $n\n",
     24        "Average : ", $avg, "\n",
     25        "SD      : ", sqrt($sumsq / ($n - 1)), "\n");