Jump to content
Sign in to follow this  
Guest rpmc

Another Xml Random Number Generator

Recommended Posts

Guest rpmc

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
×
×
  • Create New...