[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Randomness

Subject: Randomness
From: Antonio Bueno <atnbueno@xxxxxxxxxx>
Date: Mon, 18 Feb 2002 19:12:43 +0100
marsaglia 2111111111
Hello everybody.

I've seen there's some interest in generating (pseudo-)random numbers.
For those like me that don't have Java in the server, maybe something
could be done with a simple RNG, like Marsaglia's "Mother-of-All".

I don't know about XPath number formats, if the necessary functions
exist or its efficiency, but here is the info:
_____________________________________________________________________
[ from http://www.agner.org/random/mother/ ]
_____________________________________________________________________

Algorithm: S = 2111111111 · Xn-4 + 1492 · Xn-3 + 1776 · Xn-2
           + 5115 · Xn-1 + C

           Xn = S modulo 2^32

           C = floor(S / 2^32)

The last four X'es and C are stored in a buffer as 32-bit unsigned
integers. The intermediate S is a 64-bit unsigned integer.

The X'es and C are initialized to random values based on a seed. They
cannot all be zero.

This algorithm is most effectively implemented in assembly language
where you have an instruction for multiplying two 32-bit integers and
get a 64-bit product. In high level languages you do not have such an
instruction, so you have to use floating point numbers with a mantissa
of at least 63 bits. Not all compilers support this precision, for
example Microsoft Visual C++ does not.

Specifications:
32-bit integer output 
cycle length is 3·10^47
very good randomness 
_____________________________________________________________________

Anyone dares to make an XSLT/XPath version? :)

Saludos,
 Antonio

http://www.webcsd.com
mailto:atnbueno@xxxxxxxxxx


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread
  • Randomness
    • Antonio Bueno - Mon, 18 Feb 2002 13:10:28 -0500 (EST) <=

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.