[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: [xquery-talk] Re: Random number generation : requ
On Wed, May 7, 2014 at 12:08 AM, Michael Kay mike@xxxxxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|