File: frequency.pl

package info (click to toggle)
libsvg-graph-perl 0.02-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 616 kB
  • sloc: perl: 2,793; makefile: 2
file content (33 lines) | stat: -rwxr-xr-x 691 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/perl
use strict;

use Statistics::Descriptive;
use Getopt::Long;

my $bin;

GetOptions('binsize|b=i' => \$bin);
my $stat = Statistics::Descriptive::Full->new;

while(<>){
  chomp;
  $stat->add_data($_);
}

if(!$bin){
  my $max = $stat->max;
  my $min = $stat->min;
  $bin = int($max - $min);
}

my %f = $stat->frequency_distribution($bin);

print "#stat:mean\t".$stat->mean."\n";
print "#stat:quartile1\t".$stat->percentile(25)."\n";
print "#stat:median\t".$stat->median."\n";
print "#stat:quartile3\t".$stat->percentile(75)."\n";
print "#stat:standard_deviation\t".$stat->standard_deviation."\n";

foreach my $p (sort {$a <=> $b} keys %f){
  print $p, "\t", $f{$p} || 0, "\n";
}