diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-09-19 17:08:40 -0400 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-09-19 17:08:40 -0400 |
| commit | 700b91c8047c0e96d319097c9bc95f70cca744f1 (patch) | |
| tree | 2a3ef2dd5e5b6a18614d0bde4fe80705cb5d24e3 /doc | |
| parent | 292c5fb43f5402bcbd2c26607543f5bfc815e8e5 (diff) | |
| download | math-utils-master.tar.gz | |
Diffstat (limited to 'doc')
| -rw-r--r-- | doc/cdf.1 | 7 | ||||
| -rw-r--r-- | doc/cumsum.1 | 123 |
2 files changed, 127 insertions, 3 deletions
@@ -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" |