In=$HOME/wisp/var/omid/coseekmo/results/re if [ -d $HOME/tmp/re ] then rm $HOME/tmp/re/* else mkdir $HOME/tmp/re fi Data="re_coc81_all re_coc81_kindmax re_coc81_kindmin re_coc81_langftn re_coc81_langmol re_coc81_modee re_coc81_modeorg re_nasa93_all re_nasa93_category_avionicsmonitoring re_nasa93_category_missionplanning re_nasa93_center_2 re_nasa93_center_5 re_nasa93_fg_g re_nasa93_mode_embedded re_nasa93_mode_semidetached re_nasa93_project_gro re_nasa93_project_sts re_nasa93_year_1975 re_nasa93_year_1980 " for d in $Data do echo $d cat $In/$d | sort -n | gawk -F, ' {sum+=$1; sum2 += $1 * $1; n++ ; data[n]=$1} function mean(sumX,n) {return sumX/n} function sd(sumSq,sumX,n) {return sqrt((sumSq-((sumX*sumX)/n))/(n-1))} function normal(m,s) {return m+box_muller()*s; } function box_muller(m,s, n,x1,x2,w) { w=1; while (w >= 1) { x1= 2.0 * rand() - 1; x2= 2.0 * rand() - 1; w = x1*x1 + x2*x2}; w = sqrt((-2.0 * log(w))/w); return x1 * w; } END {mu = mean(sum,n); sigma = sd(sum2,sum,n); comg = "sort -n > $HOME/tmp/re/" FILE ".g" comraw = "sort -n > $HOME/tmp/re/" FILE ".raw" for(i=int(n*0.5);i<=int(n*0.9999);i++) { #for(i=1;i<=n;i++) { printf("%20.20f\n", data[i]) | comraw printf("%20.20f\n", normal(mu,sigma)) | comg } }' FILE=$d #max=`wc -l $HOME/tmp/re/${d}.raw | gawk '{print $1*1.1}'` gnuplot<<-EOF set notitle set noylabel set ylabel "relative error (RE)" set xlabel "all RE, sorted" set noxtics set key top left set xrange[1:40000] set size 0.5,0.5 set terminal postscript eps "Helvetica" 15 set output "$HOME/tmp/re/${d}.eps" plot "$HOME/tmp/re/${d}.g" title "Gaussian" with points 5,\ "$HOME/tmp/re/${d}.raw" title "Actual" with lines EOF epstopdf $HOME/tmp/re/${d}.eps done