## error measures are: 'MAR','MMRE','MMER','MBRE','MIBRE','MDMRE','Pred25'
#############################################################################################################
sortCols() { cat myErrorMeasure6LossValues.txt | awk 'BEGIN{FS=","; OFS=","}{for(i=1;i<=NF;i++) $i=$i*100/99; print $11,$81,$64,$65,$4,$5,$14,$15,$91,$74,$75,$101,$71,$94,$95,$78,$18,$79,$99,$86,$77,$6,$98,$87,$7,$21,$84,$85,$39,$76,$93,$68,$8,$97,$96,$61,$34,$35,$54,$55,$69,$82,$9,$72,$92,$19,$51,$62,$2,$29,$89,$44,$45,$90,$41,$49,$10,$52,$58,$3,$59,$100,$66,$38,$80,$73,$63,$28,$24,$25,$88,$31,$42,$56,$12,$17,$16,$46,$48,$57,$67,$47,$37,$32,$43,$27,$53,$26,$36,$13,$22,$33,$60,$70,$50,$20,$30,$40,$23,$83}' 
}


printRows(){

	local rows="19 16 7 5 1 4 14 8 12 3 2 17 10 13 15 18 11 6 9 20"
	local tmp=~/tmp/crap
	sortCols > $tmp

	for val in $rows; do
		cat $tmp | awk 'NR=='$val'{print $0}'
	done

}

# separate data into subsets w.r.t. loss percentage
printRows |gawk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1 && $i<T2) print NR,i}' T1=0 T2=15> 2d0.dat
printRows |gawk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1 && $i<T2) print NR,i}' T1=15 T2=30> 2d15.dat
printRows |gawk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1 && $i<T2) print NR,i}' T1=30 T2=60> 2d30.dat
printRows |gawk -F, '{OFS="\t"; for(i=1;i<=NF;i++) if ($i>= T1) print NR,i}' T1=60 > 2d60.dat

gnuplot <<EOF
set xrange [0:35]
set yrange [0:102]
set xlabel "Dataset Indices" font "Times-Roman,20"
set ylabel "Pre-Processor+Method Indices" font "Times-Roman,20"
set title "MdMRE - Percentage Loss Values "font "Times-Roman,20"
set terminal postscript eps
set output "mdmreLossValues.eps
set key bottom right
set size 0.7,1.5
set pointsize 1
plot "2d0.dat" title "15%> & >=0%" with points 0 0,\
"2d15.dat" title "30%> & >=15%" with points 0 1,\
"2d30.dat" title "60%> & >=30%" with points 0 6 ,\
"2d60.dat" title ">=60%" with points 1 5
EOF
epstopdf mdmreLossValues.eps
