# Definiere die Breite der Bins (“bin width”, ∆x)
# und eine sog. “binning”-Funktion:
hist(x,s)=s*ceil(x/s) - 0.5*s

# Die Funktion ceil(x) rundet den Wert von x ab
# Die Anzahl der Datenpunkte (für die Normierung)
set datafile separator ","
stats datei1 ; N = STATS_records
set output ausgabe1
plot datei1  using 1:2
ymax = GPVAL_DATA_Y_MAX
ymin = GPVAL_DATA_Y_MIN
bw = (10.0 ** floor(log10(ymax))) /10.0

set output ausgabe1
set size 0.95,0.95
set origin 0.03,0.03
set grid #linestyle 30, linestyle 31
set grid xtics mxtics ytics mytics

set title title1
#"Pingzeit Verlauf"
set xlabel "seq."
set ylabel "Zeit in ms"
#set yrange [*<0:*]
set logscale y
set mytics
if ( miss >0 ) {
plot datei1  using 1:2 with linespoints lc rgb "blue" pt 7 ps 0.3 title "rtt", \
     datei2  using 1:(ymax * 0.95) with impulses lc rgb "red" title "loss"
} else {
plot datei1  using 1:2 with linespoints lc rgb "blue" pt 7 ps 0.3 title "rtt"
}
# mit logscale y muss man die max und min Werte entsprechend korrigieren
print "   Breite ", bw, " ms ", ymax
set boxwidth bw
print title1
print datum

set output ausgabe2
set title title2
set xlabel "Pingzeit in ms"
set ylabel "Relative Häufigkeit in %"
unset logscale y
set xrange [0:]
set yrange [0:*]
#set ytics default
unset mytics
# Das Histogramm wird erzeugt und dargestellt durch:
plot datei1 u (hist($2,bw)):(1./N*100.0) smooth frequency with boxes lc rgb "blue" title "success"
# Dabei werden die Daten in Bins aufgeteilt (“gebinnt”) und durch die
# Direktive smooth frequency die Treffer eines jeden Bins aufsummiert;
# das Ergebnis wird als Funktion des Bins aufgetragen, und zwar mit
# Balken (“boxes”).
