#! /bin/sh # histgraph < data-file > image-file img=png fitlog=/tmp/fitlog fitout=/tmp/fit imagelog=/tmp/plotlog fitx='$X1'; fitwt='(1)' #fitx='$X1'; fitwt='(\$0<($FSz/2)?.25:1)' while [ $# -gt 0 ]; do case $1 in -png) img=png; shift ;; -pbm) img=pbm; shift ;; -gif) img=gif; shift ;; -forg) fitx='$Xorg'; fitwt='(1)'; shift ;; -f01) fitx='$X0'; fitwt='(1)'; shift ;; -f11) fitx='$X1'; fitwt='(1)'; shift ;; -f0y) fitx='$X0'; fitwt='(\$2<3?.25:1)'; shift ;; -f1y) fitx='$X1'; fitwt='(\$2<3?.25:1)'; shift ;; -f0x) fitx='$X0'; fitwt='(\$0>($FSz/2)?.25:1)'; shift ;; -f1x) fitx='$X1'; fitwt='(\$0>($FSz/2)?.25:1)'; shift ;; -l) shift; fitlog=$1; shift ;; -x) shift; fitx="$1"; shift ;; -wt) shift; fitwt="$1"; shift ;; *) echo "Bad arg: $1."; exit ;; esac done rm $fitlog 2> /dev/null sed -n ' 1 w /tmp/params /^Level.*:/w /tmp/stats /^Average.*:/w /tmp/avg /^Small.*:/w /tmp/clust /Final Scale/w /tmp/scale /^Edge Histogram/,/Totals/{ s:[ ]$:: /^[0-9]/w /tmp/test } ' tr ":\t " " \n" /tmp/data bigname=`sed 's/^.*: //' /tmp/params` name=`sed 's/:.*//' /tmp/params` edges=`sed 's/^.*Edges.*= *//' /tmp/stats` stats=`sed 's/^.*: //;s/;.*//' /tmp/stats` clust=`sed 's/^.*=//' /tmp/clust` search=`sed 's/;.*//;s/^.*=//' /tmp/avg` scale0=`sed 's/^.*=//' /tmp/scale` gamma0=`echo $bigname | sed -n '/G *=/s/^.*-//p'` cat - </tmp/fitin scale=${scale0:-10000} gamma=${gamma0:-3} EOF title="$bigname E=$edges Levels:$stats" title1="$name:$edges PL/DF/BF/Sh=$search CC/CP/D=$clust" FSz=`wc -l < /tmp/data | sed 's: ::g'` if [ $FSz -lt 10 ]; then FstX=3; else FstX=5; fi Xorg=`sed -n "$FstX s/ .*//p" /tmp/data` eval `awk 'BEGIN{Y0=0} $2>=Y0{N=0;Y0=$2;X0=$1;N0=NR} $2 $fitlog cat /tmp/test >> $fitlog echo "Fit Data: FSz=$FSz N0=$N0 X0=$X0 N1=$N1 X1=$X1" >> $fitlog echo "Fit Params: X=$X Wt=$Wt" >> $fitlog echo "Initial Fit Parameters:" >> $fitlog cat /tmp/fitin >> $fitlog FIT_LOG=$fitlog; export FIT_LOG; gnuplot - << EOF > /tmp/fit 2>&1 f(x)=scale*x**-gamma; fit [$X:] f(x) "/tmp/data" \ using 1:2:$Wt via "/tmp/fitin" EOF scale=`sed -n '/scale.*+\/-/{s:^.*= ::;s: .*$::;s:\.[0-9]*::;p;}' $fitlog` #scale=`sed -n '/scale.*+\/-/{s:^.*= ::;s: .*$::;p;}' $fitlog` gamma=`sed -n '/gamma.*+\/-/{s:^.*= ::;s: .*$::;p;}' $fitlog` stdfit=`sed -n '/stdfit/s/^.*: //p' $fitlog` chisq=`sed -n '/chisquare/s/^.*: //p' $fitlog` echo "Fit Params:" >> $fitlog echo "scale=$scale gamma=$gamma stdfit=$stdfit chisq=$chisq" >> $fitlog Eqn="" if [ "$scale" != "" ]; then Eqn="$scale*x**-$gamma t \"$scale*x**-$gamma[$X/$stdfit/$chisq]\", " Eqn=`echo $Eqn|sed 's:\(\.[0-9][0-9]\)[0-9]*\([^0-9]\):\1\2:g'` fi if [ "$scale0" != "" ]; then Eqn="$Eqn $scale0*x**-$gamma0, "; fi gnuplot - << EOF 2>$imagelog set logscale x; set logscale y; set grid mxtics mytics xtics ytics set terminal $img color; set output set x2label "$title" set ylabel "Nodes w/ EdgeCount Edges" set xlabel "EdgeCount\n$title1" plot [.9:][.4:] $Eqn "/tmp/data" t "datafile" EOF exit ##################################################### files="RdE-1000-1-2.5 Bag1000-8-8 SmW-2000-4-0.1" for f in $files;do ./histgraph/tmp/$f.png;xv /tmp/$f.png& done ./histgraph -x '`expr $X1 + 2`' 20?2:1) via "/tmp/fitin" f(x)=scale*x**-gamma;fit[:]f(x)"/tmp/data" u 1:2:(\$2<3?.025:1) via "/tmp/fitin" f(x)=scale*x**-gamma;fit[:]f(x)"/tmp/data"u 1:2:(\$1**-2) via "/tmp/fitin" f(x)=scale*x**-gamma; fit [$X0:]f(x)"/tmp/data" u 1:2:(\$1) via "/tmp/fitin" f(x)=scale*x**-gamma; fit [$X0:]f(x)"/tmp/data" u 1:2:(\$1) via scale,gamma f(x)=scale*x**-gamma; fit f(x) "/tmp/data" using 1:2:(\$1) via scale,gamma f(x)=scale*x**-gamma; fit f(x) "/tmp/data" via scale,gamma using 1:2:(\$2<3?.25:1) via "/tmp/fitin" echo X0=$X0 Wt="$Wt" exit case $FSz in [0-2]) FstX=1 ;; [3-5]) FstX=2 ;; [6-9]) FstX=3 ;; *) FstX=4 ;; esac if [ $FSz -lt 10 ]; then FstX=3; else FstX=5; fi X0=`sed -n "$FstX s/ .*//p" /tmp/data` X0=`awk 'BEGIN{Y0=0}{if($2>Y0){Y0=$2}else{print $1;exit}}'