coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generate random numbers with shuf


From: Pádraig Brady
Subject: Re: Generate random numbers with shuf
Date: Fri, 05 Jul 2013 00:40:49 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 07/04/2013 09:41 PM, Assaf Gordon wrote:
> Hello,
> 
> Regarding old discussion here:
> http://lists.gnu.org/archive/html/coreutils/2011-02/msg00030.html
> 
> Attached is a patch with adds "--repetition" option to shuf, enabling random 
> number generation with repetitions.
> 
> Example:
> 
> to generate 50 values between 0 and 9:
>   $ shuf --rep -i0-9 -n50
> 
> Comments are welcomed,
>  -gordon


I like this.
--repetition seems to be a very good interface too,
since it aligns with standard math nomenclature in regard to permutations.

I'd prefer to generalize it though, to supporting stdin as well as -i.
You could disable reservoir-sampling in that case, thus buffering
all input and allowing trivial selection from that.

For extra bonus points though one could use reservoir-sampling with replacement:
https://www.siam.org/proceedings/datamining/2004/dm04_053parkb.pdf
That could/should be done as a separate patch though.

cheers,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]