Archived

This topic is now archived and is closed to further replies.

Guest rpmc

Another Xml Random Number Generator

Recommended Posts

In the 'For What It's Worth' category, here's another XML Random Number generator. This one is based on a multiplicative linear congruential generator method described by Pierre L'Ecuyer in a 1988 Association for Computing Machinery paper. The code below generates a random number between (but never equal to) 0 and 1 every Update cycle. It has a period of 2.30584 X 10^18, meaning that at an Update cycle rate of 18, the pattern will not repeat for a little over 4 billion years.

<Macro Name="XMLRandom">	(L:RandomSeed1,number) 0 == (L:RandomSeed2,number) 0 == ||		if{			(P:Absolute Time,seconds) abs d 2147483563 % (>L:RandomSeed1,number)			sqrt d d * * abs 2147483599 % (>L:RandomSeed2,number)		}	(L:RandomSeed1,number) 40014 * 2147483563 % (>L:RandomSeed1,number) 	(L:RandomSeed2,number) 40692 * 2147483399 % (>L:RandomSeed2,number) 	(L:RandomSeed1,number) (L:RandomSeed2,number) - 2147483563 / s1	l1 0 < if{ l1 ++ s1 }	l1</Macro><Update>	@XMLRandom (>L:RandomNumber,number)</Update>

L'Ecuyer, Pierre, 1988, Efficient and Portable Combined Random Number Generators, Association for Computing Machineryhttp://portal.acm.org/citation.cfm?id=6295...FTOKEN=18338685Acknowledgements owed to Ron Freimuth, Nike Pike, and Tom (taquilo) who have posted xml random number code in this forum before. The MLCG code above is another variety. Acknowledgement also to my son, Robbie, for writing the xml snippet based on the L'Ecuyer paper.Bob

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!