From efc6fb696354026c611de129d30a9d41ac400967 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 7 Apr 2010 22:12:02 +0200 Subject: Add scripts/frequency and scripts/histogram --- scripts/frequency | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 scripts/frequency (limited to 'scripts/frequency') diff --git a/scripts/frequency b/scripts/frequency new file mode 100755 index 00000000..1f9c66e6 --- /dev/null +++ b/scripts/frequency @@ -0,0 +1,51 @@ +#!/usr/bin/perl -w + +use strict; + +my $bins = 200; +open(FH, $ARGV[0]); + +my $min = 99999999999999999999.0; +my $max = 0.0; +my $line; + +while ( $line = ) { + + chomp($line); + if ( $line < $min ) { + $min = $line; + } + if ( $line > $max ) { + $max = $line; + } + +} + +printf("%f -> %f\n", $min, $max); + +seek(FH, 0, 0); + +my $binsize = ($max+1-$min)/$bins; +my @hist; +my $i; + +for ( $i=0; $i<$bins; $i++ ) { + $hist[$i] = 0; +} + +while ( $line = ) { + + my $bin; + + chomp($line); + + $bin = int(($line-$min)/$binsize); + $hist[$bin]++; + +} + +for ( $i=0; $i<$bins; $i++ ) { + printf("%f\t%i\n", $min+(($i+0.5)*$binsize), $hist[$i]); +} + +close(FH); -- cgit v1.2.3