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