.\" 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"