#!/usr/local/bin/perl -w # histo2.p reads in a simple histogram and changes the bin sizes to # make it smoother looking # # this is intended to help a human come up with a proper hypothesis. $min=10; # how many counts to have in a bin # $max=1; # $bins=50; $c=1; $col=-1; $scale=1; $origsize = 1.0 ; # bin widths to start with # How to override min and max values with command line eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; # read in lines until we go over the top $in_bin = 0 ; while (<>) { # $line++ ; s/^[\s\[]*//; ($x,$y,$rest) = split(/[\s\,\t]+/,$_); if ( !$in_bin ) { # starting_new_bin ; $lhs = $x ; $in_bin = 1; $count = 0 ; } $rhs = $x ; $count += $y ; if ( $count > $min ) { # leave this bin &spit() ; $in_bin = 0 ; } } if ( $in_bin ) { &spit() ; } sub spit { $cx = ( $lhs + $rhs ) / 2.0 ; $width = ( $rhs + $origsize - $lhs ) ; $newy = $count / $width ; printf "%10g\t%10g\t%10g\n" , $cx , $newy , $count ; }