summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-09-19 17:08:40 -0400
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-09-19 17:08:40 -0400
commit700b91c8047c0e96d319097c9bc95f70cca744f1 (patch)
tree2a3ef2dd5e5b6a18614d0bde4fe80705cb5d24e3
parent292c5fb43f5402bcbd2c26607543f5bfc815e8e5 (diff)
downloadmath-utils-700b91c8047c0e96d319097c9bc95f70cca744f1.tar.gz
Documentation updatesHEADmaster
-rw-r--r--Makefile2
-rw-r--r--doc/cdf.17
-rw-r--r--doc/cumsum.1123
3 files changed, 129 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index f0b9b83..ecb1e4b 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,7 @@ install: all
@echo "Installing man pages to $(MANDIR)..."
@mkdir -p $(MANDIR)
@cp doc/cdf.1 $(MANDIR)/
+ @cp doc/cumsum.1 $(MANDIR)/
@echo "Installation complete."
# Uninstall target
@@ -49,6 +50,7 @@ uninstall:
@rm -f $(BINDIR)/cumsum
@echo "Removing man pages from $(MANDIR)..."
@rm -f $(MANDIR)/cdf.1
+ @rm -f $(MANDIR)/cumsum.1
@echo "Uninstallation complete."
# Help target
diff --git a/doc/cdf.1 b/doc/cdf.1
index 06f3a49..00d27a3 100644
--- a/doc/cdf.1
+++ b/doc/cdf.1
@@ -70,7 +70,7 @@ This format was selected to be compatible with the output of the uniq -c command
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
-Calculate CDF from integer data in a file:
+Calculating the CDF of integer data in a file:
.Bd -literal -offset indent
$ cdf data.txt
0.300000000000000 10
@@ -78,7 +78,7 @@ $ cdf data.txt
1.000000000000000 20
.Ed
.Pp
-Generate complementary CDF in a pipeline:
+Calculating the complementary CDF as part of a pipeline:
.Bd -literal -offset indent
$ awk '{print $2, $1}' measurements.dat | cdf -r -f
1.000000000000000 1.234000
@@ -86,7 +86,8 @@ $ awk '{print $2, $1}' measurements.dat | cdf -r -f
0.400000000000000 4.890000
.Ed
.Pp
-Use standard tools for pre-processing:
+Using standard tools to preprocess a raw list of measurements
+into a CDF:
.Bd -literal -offset indent
$ sort -n data.txt | uniq -c | cdf > dist.cdf
.Ed
diff --git a/doc/cumsum.1 b/doc/cumsum.1
new file mode 100644
index 0000000..f55da49
--- /dev/null
+++ b/doc/cumsum.1
@@ -0,0 +1,123 @@
+.\" Copyright (c) 2025
+.\" Manual page for cumsum(1)
+.\"
+.Dd $Mdocdate$
+.Dt CUMSUM 1
+.Os
+.Sh NAME
+.Nm cumsum
+.Nd calculate cumulative sums from numeric data
+.Sh SYNOPSIS
+.Nm cumsum
+.Op Fl f | u
+.Op Fl r | w Ar window_size
+.Op Fl h
+.Op Ar file
+.Sh DESCRIPTION
+The
+.Nm
+utility computes cumulative sums from input data consisting of numeric values.
+It reads data from
+.Ar file
+or standard input if no file is specified, and outputs cumulative sums
+suitable for statistical analysis and plotting.
+.Pp
+Input data must consist of whitespace-separated numeric values. The utility
+supports three modes of operation:
+.Bl -bullet
+.It
+Default mode: outputs the total sum of all input values
+.It
+Running sum mode (with
+.Fl r
+): outputs the cumulative sum after each input value
+.It
+Windowed sum mode (with
+.Fl w
+): outputs the sum of the last N values in a sliding window
+.El
+.Pp
+.Sh OPTIONS
+.Bl -tag -width Ds
+.It Fl f
+Read input values as floats.
+.It Fl u
+Read input values as unsigned integers
+.It Fl r
+Generate running cumulative sums, outputting the sum after each input value.
+.It Fl w Ar window_size
+Generate windowed sums using a sliding window of the specified size.
+Each output line represents the sum of the last
+.Ar window_size
+values.
+.It Fl h
+Display usage information and exit.
+.El
+.Pp
+If
+.Fl f
+or
+.Fl u
+is not specified, the input values will be read as signed integers by
+default.
+.Pp
+The
+.Fl r
+and
+.Fl w
+options are mutually exclusive.
+.Sh INPUT FORMAT
+Input consists of whitespace-separated numeric values, one per line or
+space-separated on the same line. Invalid tokens are skipped with a warning.
+.Pp
+Example input:
+.Bd -literal -offset indent
+1
+2
+3
+4
+5
+.Ed
+.Pp
+.Sh EXIT STATUS
+.Ex -std
+.Sh EXAMPLES
+Calculating the total sum of integer data in a file:
+.Bd -literal -offset indent
+$ cumsum data.txt
+15
+.Ed
+.Pp
+Calculating running cumulative sums:
+.Bd -literal -offset indent
+$ cumsum -r data.txt
+1
+3
+6
+10
+15
+.Ed
+.Pp
+Calculating windowed sums with a window size of 3:
+.Bd -literal -offset indent
+$ cumsum -w 3 data.txt
+1
+3
+6
+9
+12
+.Ed
+.Pp
+Processing float data:
+.Bd -literal -offset indent
+$ cumsum -f measurements.dat
+123.456000
+.Ed
+.Sh SEE ALSO
+.Xr awk 1 ,
+.Xr paste 1 ,
+.Xr seq 1 ,
+.Xr gnuplot 1
+.Sh AUTHORS
+.An Douglas B. Rumbaugh
+.Mt "dbrumbaugh@harrisburgu.edu"