#!/usr/local/bin/perl # goes through a code/cg report file and creates separate # gnuplot files with scatterplots for # successes, failures, and pseudo-successes. $corr = "g/corr" ; $ok = "g/ok" ; $wrong = "g/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 $size="0.7"; $omitw=0; # whether to omit the wrongs from the plot $dotw=0; # whether to use dots for wrongs 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 , $fa , $err , $rest ) = 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 = $fa."\t".$err."\n" ; if ( $count == 0 ) { print CORR $out ; } elsif ( $score < $t ) { 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" ; } print "# gnuplot\n" ; print "set nokey\n" ; if($labels){ if ( $fAnum ) { print "set xlabel 'average number of 1s per row of A'\n" ; } else { print "set xlabel 'density of 1s in A'\n" ; } print "set ylabel 'noise level'\n" ; } if ( $xmax) { print "set xrange [0:$xmax]\n" ; } if ( $ymax) { print "set yrange [0:$ymax]\n" ; } print "set size $size,$size\n" ; printf "set arrow 1 from 10,%7f to 0,%7f nohead\n" , $gam , $gam ; print "set term post \n" ; print "set output '$psfile'\n" ; print "# gnuplot\n" ; print "plot '$corr' u 1:2 t 'correct' w p 3 3, '$ok' u 1:2 t 'ok' w p 6 6" ; 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" ; }