aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranklin Wei <me@fwei.tk>2018-07-09 21:11:00 -0400
committerFranklin Wei <me@fwei.tk>2018-07-09 21:11:00 -0400
commit26210992dc61b5b77972074c6da411de5bcce48e (patch)
tree10424ac2f99a7022775c5d0b6c7aa6e4dbca5d6d
parent9d1c4774b274aed0d06551238462a4535cdda2f1 (diff)
downloadcsaa-26210992dc61b5b77972074c6da411de5bcce48e.zip
csaa-26210992dc61b5b77972074c6da411de5bcce48e.tar.gz
csaa-26210992dc61b5b77972074c6da411de5bcce48e.tar.bz2
csaa-26210992dc61b5b77972074c6da411de5bcce48e.tar.xz
Add error bars to generated graph
-rw-r--r--graph.gnu12
-rw-r--r--postprocess.cpp31
-rwxr-xr-xtabulate.sh2
3 files changed, 34 insertions, 11 deletions
diff --git a/graph.gnu b/graph.gnu
index dc09cf8..2e4a137 100644
--- a/graph.gnu
+++ b/graph.gnu
@@ -1,25 +1,25 @@
set xlabel "logleaves"
set ylabel "avg time per operation (sec)"
set yrange [0:]
-
+set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps .1
set terminal eps
set output "graph_create.eps"
-plot "results/final_data_create.txt" u 1:2 w lines title "Create";
+plot "results/final_data_create.txt" u 1:2:3 w yerrorbars ls 1 title "1 SE", '' u 1:2 w lines ls 1 title "Create";
set output "graph_modify.eps"
-plot "results/final_data_modify.txt" u 1:2 w lines title "Modify";
+plot "results/final_data_modify.txt" u 1:2:3 w yerrorbars ls 1 title "1 SE", '' u 1:2 w lines ls 1 title "Modify";
set output "graph_retrieve.eps"
-plot "results/final_data_retrieve.txt" u 1:2 w lines title "Retrieve";
+plot "results/final_data_retrieve.txt" u 1:2:3 w yerrorbars ls 1 title "1 SE", '' u 1:2 w lines ls 1 title "Retrieve";
set output "graph_modifyenc.eps"
-plot "results/final_data_modifyenc.txt" u 1:2 w lines title "Modify (enc)";
+plot "results/final_data_modifyenc.txt" u 1:2:3 w yerrorbars ls 1 title "1 SE", '' u 1:2 w lines ls 1 title "Modify (encrypted)";
set output "graph_retrieveenc.eps"
-plot "results/final_data_retrieveenc.txt" u 1:2 w lines title "Retrieve (enc)";
+plot "results/final_data_retrieveenc.txt" u 1:2:3 w yerrorbars ls 1 title "1 SE", '' u 1:2 w lines ls 1 title "Retrieve (encrypted)";
diff --git a/postprocess.cpp b/postprocess.cpp
index c57d9ff..2613bc6 100644
--- a/postprocess.cpp
+++ b/postprocess.cpp
@@ -1,7 +1,12 @@
#include <iostream>
#include <stdio.h>
+#include <cmath>
+#include <cstring>
+
using namespace std;
+/* Huge hack. */
+
/* post-process the output of tabulate.sh */
/* input:
[x1] [y1_0]
@@ -13,14 +18,15 @@ using namespace std;
[x] is an integer up to 100
*/
/* output:
- [x1] [average y1]/2^[x1] [stddev y1]
+ [x1] [average y1]/2^[x1] [stderr y1]
*/
-static double sums[100] = { 0 }, means[100] = { 0 }, deltasq[100] = { 0 };
+static double values[100][100], sums[100], means[100], stddevs[100], stderrs[100];
static int counts[100] = { 0 };
int main()
{
+ memset(counts, 0, sizeof(counts));
while(cin)
{
int x;
@@ -29,7 +35,9 @@ int main()
long long div = 1 << x;
- sums[x] += y / div;
+ values[x][counts[x]] = y / div;
+ sums[x] += values[x][counts[x]];
+
counts[x]++;
}
for(int i = 0; i < 100; ++i)
@@ -37,7 +45,22 @@ int main()
if(counts[i])
{
means[i] = sums[i] / counts[i];
- printf("%d %g\n", i, means[i]);
+
+ double var = 0;
+ for(int j = 0; j < counts[i]; ++j)
+ {
+ double del = (values[i][j] - means[i]);
+ var += del * del;
+ }
+
+ if(counts[i] == 0)
+ stddevs[i] = 0;
+ else
+ stddevs[i] = sqrt(var / (counts[i] - 1));
+
+ stderrs[i] = stddevs[i] / sqrt(counts[i]);
+
+ printf("%d %g %g\n", i, means[i], stderrs[i]);
}
}
}
diff --git a/tabulate.sh b/tabulate.sh
index aaf20be..f85a2cf 100755
--- a/tabulate.sh
+++ b/tabulate.sh
@@ -2,7 +2,7 @@
for i in `seq 2 14`
do
rm -f all_"$i".txt
- for j in `seq 1 1`
+ for j in `seq 1 4`
do
echo -n "$i $j " >> all_"$i".txt
cat run_"$i"_"$j".txt | awk '/Elapsed/ || /Maximum/ || /User time/ || /System time/' | awk 'BEGIN{line=0}{if(line%4<=1)printf($4" ");if(line %4==2)printf($8" ");if(line%4==3)printf($6" ");}{line+=1}END{printf("\n");}' >> all_"$i".txt