trandcounts.1 - numtools - perform numerical operations on vectors and matrices in unix pipes
 (HTM) git clone git://src.adamsgaard.dk/numtools
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       trandcounts.1 (2415B)
       ---
            1 .Dd $Mdocdate$
            2 .Dt RANDCOUNTS 1
            3 .Os
            4 .Sh NAME
            5 .Nm randcounts
            6 .Nd produces random counts in weighted bins
            7 .Sh SYNOPSIS
            8 .Nm
            9 .Op Fl d Ar delimstr
           10 .Op Fl n
           11 .Op Fl N Ar num
           12 .Op Fl p Ar prec
           13 .Op Fl r Ar repeats
           14 .Op Fl R
           15 .Op Fl s Ar seed
           16 .Ar weight1
           17 .Op Ar weight2 ...
           18 .Sh DESCRIPTION
           19 .Nm
           20 randomly distributes a number of points in a number of bins according to the
           21 weights assigned to them.
           22 This program can be invoked with an arbitrary number of weights, each
           23 supplied as arguments and with values in the range ]0;1].
           24 The number of weights determine the number of bins to put the points into.
           25 The sum of weights must equal 1.0.
           26 The binning is performed using a pseudo-random number generator, seeded
           27 from current time of day with microsecond resolution.
           28 Invocations of
           29 .Nm
           30 within the same microsecond will produce the same result.
           31 .Pp
           32 Output consists of the number of points per bin, in tab-separated format.
           33 .Pp
           34 The options are as follows:
           35 .Bl -tag -width Ds
           36 .It Fl d Ar delimstr
           37 Separate output values by
           38 .Ar delimstr .
           39 The default delimiter is tab characters.
           40 .It Fl n
           41 Do not print a newline after the final value.
           42 .It Fl N Ar num
           43 Number of points to place in the bins.
           44 The default is 1.
           45 .It Fl r Ar repeats
           46 Repeat the binning several times, with one realization per line of output.
           47 .It Fl R
           48 Show the output as ratios (in the range [0;1]) instead of counts.
           49 .It Fl p Ar prec
           50 Print the output values with
           51 .Ar prec
           52 digits of precision.
           53 This option only applies if called with the
           54 .Fl R
           55 option.
           56 By default, the output is printed with 17 digits of precision, which is
           57 full double precision on 64-bit systems.
           58 .It Fl s Ar seed
           59 Seed the pseudo-random number generator with this value, which is used
           60 to generate reproducible binning.
           61 .El
           62 .Sh EXAMPLES
           63 Put one point in four bins with equal probability (25%).
           64 Due to the randomness, your output may differ:
           65 .Dl $ randcounts 0.25 0.25 0.25 0.25
           66 .Dl 0   1   0   0
           67 .Pp
           68 Put 100 points in two bins with 75% and 25% probability, respectively,
           69 and print the count ratios for each bin:
           70 .Dl $ randcounts -N 100 -R 0.75 0.25
           71 .Dl 0.72999999999999998        0.27000000000000002
           72 .Pp
           73 Put 100 points in three equal bins 1000 times, and calculate the average
           74 bin sizes with
           75 .Xr mean 1 :
           76 .Dl $ randcounts -n 100 -r 1000 0.333 0.333 0.334 | mean
           77 .Dl 33.067   32.82   34.113
           78 .Sh SEE ALSO
           79 .Xr mean 1 ,
           80 .Xr range 1 ,
           81 .Xr rangetest 1 ,
           82 .Xr sum 1
           83 .Sh AUTHORS
           84 .An Anders Damsgaard Aq Mt anders@adamsgaard.dk