Utils: 1-column-statistics added, which includes awk scripts that calculate min,...
authorP2P-Next <p2p@p2p-next.grid.pub.ro>
Thu, 30 Jun 2011 10:19:01 +0000 (13:19 +0300)
committerP2P-Next <p2p@p2p-next.grid.pub.ro>
Thu, 30 Jun 2011 10:19:01 +0000 (13:19 +0300)
Utils/1-column-statistics/avg [new file with mode: 0755]
Utils/1-column-statistics/max [new file with mode: 0755]
Utils/1-column-statistics/min [new file with mode: 0755]
Utils/1-column-statistics/stdev [new file with mode: 0755]

diff --git a/Utils/1-column-statistics/avg b/Utils/1-column-statistics/avg
new file mode 100755 (executable)
index 0000000..5e6c40e
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/awk -f
+# Calculates the average value of 1 column.
+
+BEGIN  {
+       sum = 0.0
+       FS = "[ \t]+"
+}
+
+/^[0-9]+/ {
+       sum += $1
+}
+
+END    {
+       printf "%f\n", sum / NR
+}
diff --git a/Utils/1-column-statistics/max b/Utils/1-column-statistics/max
new file mode 100755 (executable)
index 0000000..8d7ae92
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/awk -f
+# Calculates the maximum value of 1 column.
+
+BEGIN  {
+       max = log(0)
+       FS = "[ \t]+"
+}
+
+/^[0-9]+/ {
+       if($1 > max)
+               max = $1
+}
+
+END    {
+       printf "%f\n", max
+}
diff --git a/Utils/1-column-statistics/min b/Utils/1-column-statistics/min
new file mode 100755 (executable)
index 0000000..100df4d
--- /dev/null
@@ -0,0 +1,16 @@
+#!/usr/bin/awk -f
+# Calculates the minumum value of 1 column.
+
+BEGIN  {
+       min = -log(0)
+       FS = "[ \t]+"
+}
+
+/^[0-9]+/ {
+       if($1 < min)
+               min = $1
+}
+
+END    {
+       printf "%f\n", min
+}
diff --git a/Utils/1-column-statistics/stdev b/Utils/1-column-statistics/stdev
new file mode 100755 (executable)
index 0000000..87985d8
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/awk -f
+# Calculates the standard deviation of 1 column.
+
+BEGIN  {
+       sum = 0.0
+       sumsq = 0.0
+       FS = "[ \t]+"
+}
+
+/^[0-9]+/ {
+       sum += $1
+       sumsq += $1 * $1
+}
+
+END    {
+       printf "%f\n", sqrt(sumsq/NR - (sum/NR)**2)
+}