commit 32276a5001156801056a92e8eb350d70e1eb3d14
parent 5ef01afdfb77b64891f0e5983f431e552f94caea
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Thu, 5 May 2022 12:16:09 +0200
begin writing randcounts.1
Diffstat:
A | randcounts.1 | | | 99 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 99 insertions(+), 0 deletions(-)
diff --git a/randcounts.1 b/randcounts.1
@@ -0,0 +1,99 @@
+.Dd $Mdocdate$
+.Dt RANDCOUNTS 1
+.Os
+.Sh NAME
+.Nm randcounts
+.Nd produces random counts in weighted bins
+.Sh SYNOPSIS
+.Nm
+.Op Fl h
+.Op Fl n Ar num
+.Op Fl s Ar seed
+.Ar weight1
+.Op Ar weight2 ...
+.Sh DESCRIPTION
+.Nm
+randomly distributes a number of points in a number of bins according to the
+weights assigned to them.
+This program can be invoked with an arbitrary number of weights, each
+supplied as arguments and with values in the range ]0;1].
+The number of weights determine the number of bins to put the points into.
+The sum of weights must equal 1.0.
+The binning is performed using a pseudo-random number generator, seeded
+from current time of day with microsecond resolution.
+Invokations of
+.Nm
+within the same microsecond will produce the same result.
+.Pp
+The options are as follows:
+.It Fl h
+Show usage information.
+.It Fl n Ar num
+Number of points to place in the bins.
+The default is 1.
+.It Fl s Ar seed
+Seed the pseudo-random number generator with this value, which is used
+to generate reproducable binning.
+.El
+.Sh EXAMPLES
+Place 10 points in 4 bins with equal probability (25%). Due to the randomness, your output may differ:
+.Pp
+.Dl $ randcounts -n 10 0.25 0.25 0.25 0.25
+.Pp
+.Dl $ range -n 4
+.Dl 0
+.Dl 0.33333
+.Dl 0.66667
+.Dl 1
+.Pp
+Same as the previous example, but with full
+.Vt double
+precision on a 64-bit system:
+.Pp
+.Dl $ range -n 4 -f '%.17g\en' 0 1
+.Dl 0
+.Dl 0.33333333333333331
+.Dl 0.66666666666666663
+.Dl 1
+.Pp
+Generate four numbers in the range ]0;1[:
+.Pp
+.Dl $ range -b -e -n 4 0 1
+.Dl 0.2
+.Dl 0.4
+.Dl 0.6
+.Dl 0.8
+.Pp
+Print ten numbers in the interval [1;10] with spaces between values:
+.Pp
+.Dl $ range -f '%g ' 1 10
+.Dl 1 2 3 4 5 6 7 8 9 10
+.Pp
+Repeat and modify a string three times:
+.Pp
+.Dl $ range -n 3 -f 'The best number is %.0g\en' 1 3
+.Dl The best number is 1
+.Dl The best number is 2
+.Dl The best number is 3
+.Pp
+Generate three numbers evenly distributed in logspace from 10^0 to 10^2:
+.Pp
+.Dl $ range -l -n 3 0 2
+.Dl 1
+.Dl 10
+.Dl 100
+.Pp
+Generate three numbers in the range [-2;-1]:
+.Pp
+.Dl $ range -n 3 -- -2 -1
+.Dl -2
+.Dl -1.5
+.Dl -1
+.Sh SEE ALSO
+.Xr max 1 ,
+.Xr mean 1 ,
+.Xr min 1 ,
+.Xr rangetest 1 ,
+.Xr sum 1
+.Sh AUTHORS
+.An Anders Damsgaard Aq Mt anders@adamsgaard.dk