#!/usr/local/bin/perl # goes through a code/cg report file and creates separate # gnuplot files with scatterplots for # successes, failures, and pseudo-successes. $labels = 1 ; # label axes. $allow_oks = 0 ; # don't use the ok facility (because score screwed up) # whether to add to the plot the M-S lines from table 5: $msl31 = 2 ; $msl32 = 0 ; $msl1 = 1 ; $msl2 = 0 ; $msl3 = 0 ; $msl4 = 0 ; $msl5 = 0 ; $msl6 = 0 ; $msl7 = 0 ; $msl8 = 0 ; $msl9 = 0 ; $msl10 = 0 ; $corr = "gms/corr" ; $ok = "gms/ok" ; $wrong = "gms/wrong" ; $t = 0.0 ; # threshold, could be set to +10.0 for example $perturb = 1 ; $cyclex = 3 ; $stepx = 0.01 ; $cycley = 3 ; $stepy = 0.01 ; $fAnum = 1 ; # whether to display fA as an average number (fA * N) $xmax = 0 ; # whether to have a range from 0:xmax $ymax = 0 ; # whether to have a range from 0:ymax $ymin = 0 ; $xmin = 0 ; $size="0.7"; $sizex="0.7"; $omitw=0; # whether to omit the wrongs from the plot $dotw=1; # whether to use dots for wrongs $show_ok = 1 ; eval "\$$1=\$2" while @ARGV && $ARGV[0]=~ /^(\w+)=(.*)/ && shift; $psfile = $ARGV[0] ; $psfile =~ s/r/g/g ; $psfile .= ".ps" ; $x0 = ($cyclex -1) / 2 ; $x = - $x0 ; $y0 = ($cycley -1) / 2 ; $y = - $y0 ; open ( CORR , ">$corr" ) ; open ( OK , ">$ok" ) ; open ( WRONG , ">$wrong" ) ; while (<>) { s/^\s*// ; ( $count , $score , $n , $m , $M , $fpol , $err , $bstl, $seed, $taps, $tr_err, $beta ) = split ; if ( $perturb ) { $fa += $x * $stepx ; $err += $y * $stepy ; $x ++ ; $y ++ ; if ( $x > $x0 ) { $x = - $x0 ; } if ( $y > $y0 ) { $y = - $y0 ; } } if ( $fAnum ) { $fa *= $n ; } $out = $taps."\t".$tr_err."\n" ; if ( $count == 0 ) { print CORR $out ; } elsif ( $score < $t && $allow_oks ) { print OK $out ; } else { print WRONG $out ; } } close ( CORR ) ; close ( OK ) ; close ( WRONG ) ; # take last values of m and n as applying throughout print "# Here\n" ; for ( $gam = 0.001 ; $gam <= 0.5 ; $gam += 0.005 ) { $h = $gam * log ( $gam ) + ( 1 - $gam ) * log ( 1 - $gam ) ; $datinfo = ( 1 + $h / log ( 2.0 ) ) * $m ; if ( $datinfo <= $n ) { last ; } # print "# $gam\n" ; } $ms_string = "" ; if ( $msl31 ) { $ms_string .= ", 'gms/MS_TABLE31' u 1:2 t 'MS(3) d=10^1' w l $msl31" ; } if ( $msl32 ) { $ms_string .= ", 'gms/MS_TABLE3' u 1:3 t 'MS(3) d=10^2' w l $msl32" ; } if ( $msl1 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:2 t 'MS d=10^1' w l $msl1" ; } if ( $msl2 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:3 t 'MS d=10^2' w l $msl2" ; } if ( $msl3 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:4 t 'MS d=10^3' w l $msl3" ; } if ( $msl4 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:5 t 'MS d=10^4' w l $msl4" ; } if ( $msl5 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:6 t 'MS d=10^5' w l" ; } if ( $msl6 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:7 t 'MS d=10^6' w l" ; } if ( $msl7 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:8 t 'MS d=10^7' w l" ; } if ( $msl8 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:9 t 'MS d=10^8' w l" ; } if ( $msl9 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:10 t 'MS d=10^9' w l" ; } if ( $msl10 ) { $ms_string .= ", 'gms/MS_TABLE' u 1:11 t 'MS d=10^10' w l" ; } print "# gnuplot\n" ; print "set nokey\n" ; if ( $labels ) { if ( $fAnum ) { print "set xlabel 'number of taps'\n" ; } else { print "set xlabel 'number of taps'\n" ; } print "set ylabel 'true noise level'\n" ; } if ( $xmax) { print "set xrange [$xmin:$xmax]\n" ; } if ( $ymax) { print "set yrange [$ymin:$ymax]\n" ; } print "set size $sizex,$size\n" ; if ( !($ymax) || ($gam < $ymax) ) { printf "set arrow 1 from %7f,%7f to %7f,%7f nohead\n" , $xmin, $gam ,$xmin+10, $gam ; } print "set term post \n" ; print "set ytics 0,0.1 \n" ; print "set output '$psfile'\n" ; print "# gnuplot\n" ; print "plot '$corr' u 1:2 t 'correct' w p 3 3"; if ( $show_ok ) { print ", '$ok' u 1:2 t 'ok' w p 6 6" ; } print "$ms_string" ; if ( $omitw ) { print "\n" ; } else { if ( $dotw ) { $wstyle = "w d 4" ; } else { $wstyle = "w p 4 4" ; } print ", '$wrong' u 1:2 t 'wrong' $wstyle\n" ; }