aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-09-08 22:49:28 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-09-08 22:49:28 +1200
commit677d0e5fdc76620253af865ca03fd602c0419047 (patch)
treea47d3e848aace0f9f2d7b7d2443f1e0588fab70a
parentAdd more color-setting attempts to rgl(1df) (diff)
downloaddotfiles-677d0e5fdc76620253af865ca03fd602c0419047.tar.gz
dotfiles-677d0e5fdc76620253af865ca03fd602c0419047.zip
Generalise mean,med,mode,tot(1df) to numbers
Not just integers
-rw-r--r--README.markdown2
-rw-r--r--bin/mean.awk2
-rw-r--r--bin/med.awk2
-rw-r--r--bin/mode.awk2
-rw-r--r--bin/tot.awk2
-rw-r--r--man/man1/mean.1df4
-rw-r--r--man/man1/med.1df4
-rw-r--r--man/man1/mode.1df4
-rw-r--r--man/man1/tot.1df2
9 files changed, 12 insertions, 12 deletions
diff --git a/README.markdown b/README.markdown
index 66c83a55..d51c961c 100644
--- a/README.markdown
+++ b/README.markdown
@@ -392,7 +392,7 @@ Installed by the `install-bin` target:
* `unf(1df)` joins lines with leading spaces to the previous line.
Intended for unfolding HTTP headers, but it should work for most RFC
822 formats.
-* Four simple aggregators for integer data:
+* Four simple aggregators for numbers:
* `mean(1df)` prints the mean.
* `med(1df)` prints the median.
* `mode(1df)` prints the first encountered mode.
diff --git a/bin/mean.awk b/bin/mean.awk
index 4506b3b0..74bdcab3 100644
--- a/bin/mean.awk
+++ b/bin/mean.awk
@@ -4,5 +4,5 @@ END {
# Error out if we read no values at all
if (!NR)
exit(1)
- printf "%u\n", tot / NR
+ print tot / NR
}
diff --git a/bin/med.awk b/bin/med.awk
index b4a899a1..34d81c41 100644
--- a/bin/med.awk
+++ b/bin/med.awk
@@ -13,7 +13,7 @@ END {
} else {
med = (vals[NR/2] + vals[NR/2+1]) / 2
}
- printf "%u\n", med
+ print med
if (warn)
exit(1)
}
diff --git a/bin/mode.awk b/bin/mode.awk
index beced1f4..500fce2a 100644
--- a/bin/mode.awk
+++ b/bin/mode.awk
@@ -9,5 +9,5 @@ END {
for (val in vals)
if (vals[val] > vals[mode])
mode = val
- printf "%u\n", mode
+ print mode
}
diff --git a/bin/tot.awk b/bin/tot.awk
index c25c718d..d1174d7b 100644
--- a/bin/tot.awk
+++ b/bin/tot.awk
@@ -1,3 +1,3 @@
# Total a column of integers
{ tot += $1 }
-END { printf "%u\n", tot }
+END { print tot }
diff --git a/man/man1/mean.1df b/man/man1/mean.1df
index 21f509f2..2fcc0f05 100644
--- a/man/man1/mean.1df
+++ b/man/man1/mean.1df
@@ -1,7 +1,7 @@
.TH MEAN 1df "September 2016" "Manual page for mean"
.SH NAME
.B mean
-\- print the mean of a list of integers
+\- print the mean of a list of numbers
.SH SYNOPSIS
printf '%u\\n' 8 1 58 |
.B mean
@@ -13,7 +13,7 @@ file
file1 file2
.SH DESCRIPTION
.B mean
-collects all the newline-delimited integers given as input, and prints the
+collects all the newline-delimited numbers given as input, and prints the
mean.
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>
diff --git a/man/man1/med.1df b/man/man1/med.1df
index 0fab7db2..70f8c131 100644
--- a/man/man1/med.1df
+++ b/man/man1/med.1df
@@ -1,7 +1,7 @@
.TH MED 1df "September 2016" "Manual page for med"
.SH NAME
.B med
-\- print the med of a list of integers
+\- print the med of a list of numbers
.SH SYNOPSIS
printf '%u\\n' 14 2 10 |
.B med
@@ -13,7 +13,7 @@ file
file1 file2
.SH DESCRIPTION
.B med
-collects all the newline-delimited integers given as input, and prints the
+collects all the newline-delimited numbers given as input, and prints the
median. It uses the floor of the mean of the two median values if the number of
records is even. The input must be sorted, and a warning will be issued if it
isn't.
diff --git a/man/man1/mode.1df b/man/man1/mode.1df
index d4727235..a0a30047 100644
--- a/man/man1/mode.1df
+++ b/man/man1/mode.1df
@@ -1,7 +1,7 @@
.TH MODE 1df "September 2016" "Manual page for mode"
.SH NAME
.B mode
-\- print the mode of a list of integers
+\- print the mode of a list of numbers
.SH SYNOPSIS
printf '%u\\n' 2 35 3 8 |
.B mode
@@ -13,7 +13,7 @@ file
file1 file2
.SH DESCRIPTION
.B mode
-collects all the newline-delimited integers given as input, and prints the
+collects all the newline-delimited numbers given as input, and prints the
mode. If two values have the same frequency (i.e. a multimodal distribution),
it will print the one that reaches that frequency first in the data set.
.SH AUTHOR
diff --git a/man/man1/tot.1df b/man/man1/tot.1df
index c098cbe1..ed2983a2 100644
--- a/man/man1/tot.1df
+++ b/man/man1/tot.1df
@@ -13,7 +13,7 @@ file
file1 file2
.SH DESCRIPTION
.B tot
-adds up all the newline-delimited integers given as input, and prints the
+adds up all the newline-delimited numbers given as input, and prints the
total.
.SH AUTHOR
Tom Ryder <tom@sanctum.geek.nz>