#! /opt/bin/dash export GDFONTPATH="/usr/share/fonts/open-sans" export GNUPLOT_DEFAULT_GDFONT="OpenSans-Semibold" title="Grover's Search, 2**16" xlabel="Number of iterations" ylabel="Average Entanglement" labels="set title \"$title\"\nset xlabel \"$xlabel\"\nset ylabel \"$ylabel\"" # input from: ./Grover -dpE 16 300 | sed '1,/^iter/d' | egrep '^E' # example: # E: 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 0.000122067 # two lines per Grover iteration # average every other line # awk 'BEGIN { n=0; E=0; print "0"; } { n = !n; if(n) next; a = 0; for( i = 2; i <= NF; ++i) a += $i; print a/(NF-1); }' Grover-E.txt | (printf "set term gif\nset output\n $labels\n plot '-' notitle with linespoints\n"; cat) | gnuplot > Grover-E.gif