xsl-list
[Top] [All Lists]

Re: [xquery-talk] [xsl] Re: Random number generation : requirements

2014-05-07 15:36:00
On Wed, May 7, 2014 at 12:08 AM, Michael Kay mike(_at_)saxonica(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
One of the inherent weaknesses of any pseudo-random number generator
where the N'th value in the sequence is a function of the (N-1)th value
is that it can get into loops. For example, if the same value appears twice 
consecutively
(which in a truly random sequence will sometimes happen),
then all subsequent values will be the same.

This is why the argument passed to the number generator needs to be
the index N of the wanted random number (as the Nth number in a
generated random sequence).

In case we have a *lazy*-generated sequence, there is no additional
cost in space and computation.

Also, this is ideal to be done within a fold (or recursion in general)
-- in this case the fold does the book-keeping (like incrementing N)
for you.

Cheers,
Dimitre
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>