aboutsummaryrefslogtreecommitdiff
path: root/scripts/frequency
blob: 1f9c66e653265f4c25628b4846ce588bea0d876f (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
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 = <FH> ) {

	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 = <FH> ) {

	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);