From: P2P-Next Date: Thu, 30 Jun 2011 10:19:01 +0000 (+0300) Subject: Utils: 1-column-statistics added, which includes awk scripts that calculate min,... X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?a=commitdiff_plain;h=a90e497927d1faa4fcffbd1e9dbd46dcc20914c9;p=p2p-testing-infrastructure.git Utils: 1-column-statistics added, which includes awk scripts that calculate min, max, avg, stdev for text files with one column of numbers --- diff --git a/Utils/1-column-statistics/avg b/Utils/1-column-statistics/avg new file mode 100755 index 0000000..5e6c40e --- /dev/null +++ b/Utils/1-column-statistics/avg @@ -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 index 0000000..8d7ae92 --- /dev/null +++ b/Utils/1-column-statistics/max @@ -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 index 0000000..100df4d --- /dev/null +++ b/Utils/1-column-statistics/min @@ -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 index 0000000..87985d8 --- /dev/null +++ b/Utils/1-column-statistics/stdev @@ -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) +}