[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Makes sort create random order
From: |
Frederik Eaton |
Subject: |
Re: [PATCH] Makes sort create random order |
Date: |
Sun, 30 Jan 2005 15:01:12 -0800 |
User-agent: |
Mutt/1.5.6+20040907i |
> > seq feature for other things as well, I think, provided it was well
> > implemented - e.g. 'jot' seems to seed it's RNG from epoch seconds,
> > which is no good, microseconds would be better. The disadvantage is
>
> Yes, but there's two points here:
> 1) There's generally a way to the user to specify a seed. Tipically this
> value is specified in the last argument (step value in nornal mode).
Would we have to keep BSD syntax? I think that's confusing - since
specifying a seed would probably be rarely done, I think it should be
a long option instead. (And I'm just saying that the default should be
that if you run it several times in a row, each time it will give
different results, which isn't the case if you use seconds. I guess
perl seeds from /dev/urandom if available, and if not then some
combination of time, $$, and something with memory allocation - but
these are unimportant details)
> 2) Today's implementations are using other randomizations than a simple
> s?rand(3) -- take for example the OpenBSD's implementation (uses ARC4),
> though this implemantion doesn't specify user-specified seed.
I'm sure something better than the libc rand implementations wouldn't
be objectionable, as long as it is actually better.
> I'd sum the good decisions of these implementations up in seq this way
>
> 1) Generate 4 random values (ranging from 1 to 4):
> $ seq -r 4
>
> 2) Generate 4 random values (ranging from 4 to 7):
> $ seq -r 4 7
>
> 3) Generate 4 random values (ranging from 4 to 7, seed 3):
> $ seq -r 4 3 7
>
> 4) Generate an endless number of random values (useful with head):
> $ seq -r
>
> Does anyone have suggestions on this?
Hmm, I don't like the syntax. As I said, having the seed where
'increment' should be is confusing. And how do I generate 8 random
values from 1 to 10000? How do I generate an endless number of random
values from 4 to 7?
Frederik
--
----------------------------------------------------------------
Frederik Eaton http://ofb.net/~frederik/
Re: [PATCH] Makes sort create random order, Bob Proulx, 2005/01/28