6 stable releases

2.1.0 Aug 17, 2023
2.0.0 Feb 2, 2021
1.2.0 Dec 20, 2020
1.1.1 Sep 14, 2020
1.0.0 Mar 15, 2020

#572 in Math

Download history 54/week @ 2024-06-16 127/week @ 2024-06-23 80/week @ 2024-06-30 77/week @ 2024-07-07 126/week @ 2024-07-14 121/week @ 2024-07-21 155/week @ 2024-07-28 96/week @ 2024-08-04 114/week @ 2024-08-11 159/week @ 2024-08-18 185/week @ 2024-08-25 76/week @ 2024-09-01 122/week @ 2024-09-08 122/week @ 2024-09-15 178/week @ 2024-09-22 383/week @ 2024-09-29

811 downloads per month
Used in meansd-cli

GPL-3.0-or-later

19KB
347 lines

meansd

Calculates mean and standard deviation.

Usage

Simple execution mode:

$ seq 1 3 | meansd
n=3  2 ± 1

Binning:

$ seq 2 7 | meansd --bin-width 5

From To Size Mean SD
   0  4    3    3  1
   5  9    3    6  1

n=6  5 ± 2

For more command line options, see meansd --help.

Resource Requirements

This tool uses so-called online algorithms. This means that the input is not stored and you can pipe an indefinite amount to this tool without increasing its memory requirement.

Memory

Without binning, VmPeak is only 4884 kB, measured with:

# generate 2 byte unsigned numbers and pipe to meansd
od -v -A n -t u2 -w2 /dev/urandom |
  meansd --progress 1000000

# measure VmPeak
rg VmPeak /proc/$(pgrep meansd)/status

With binning, the memory requirements increase only ever so slightly per bin.

CPU

During the memory tests, my observation was that meansd consumes the numbers faster than the random number generator can produce them. While od was at 100% CPU utilization, meansd was at about 50% without binning and 90% with binning.

Dependencies

~240KB