Random of zero

Wil Dijkstra W.Dijkstra at fsw.vu.nl
Wed May 14 06:12:00 EDT 2003


The maximum of the random parameter is apparently 2^31-1.
The integer limit of MC? Try this:
  put 2^53-1 into x
  put x & cr & x+1 & cr & x+2

How does the random function work?
Most, if not all random functions use:
z[n] = a * z [n-1] mod m
a and m are positive integers. The seed (z[0]) should be a positive integer (usually based on the number of ticks).
which produces a random number 0,1,2,...,m-1

Generally (for statistical use), the numbers a and m are selected in such a way that the number 0 is excluded and a random number 1,2,3,...,m-1 is generated. Next, the generated number is divided by m (u[n] = z[n]/m) , to generate a real number >0 and <1.

A common choice for a and m is:
  a = 630360016
  m = 2^31-1
which excludes 0. Quite likely, these numbers are used in MC too.

Wil Dijkstra

> Shari, 
> 
> Consider that the function random(x)-1 = right result for any x < (2^64)-1 (the integer limit of MC - I didn't test this limit lately though)... 
> 
> Naturally if you assume 0 to be a number and/or part of your answer. Remember those problems with 0-255 = 256 values? 
> 
> The proof I wrote the day this thread was first posted but I didn't post it since you probably already think im such a nuts... 
> 
> cheers 
> Xavier 
> 
> 
> 
> ---------------------=---------------------
> Xavier Bury
> TNS NT LAN Server
> ext 6465 
> 
> 
> 
> 	Shari <gypsyware at earthlink.net> 
> Sent by: metacard-admin at lists.runrev.com 
> 
> 13/05/03 14:18 
> Please respond to metacard 
>         
>         To:        metacard at lists.runrev.com 
>         cc:        ^ 
>         Subject:        RE: Random of zero 	
> 
> 
> 
> >It is clear that you read the MetaTalk entry for random, and 
> >likewise it is clear that you chose to try to use the function 
> >outside of its clearly documented scope.
> 
> The assumption that random(0) would obviously be 0 was made based on 
> general principles.  Not on Metatalk itself.  I did not expect to 
> have to look up what would seem to be a simple function.
> 
> It was not until the handler failed, and I discovered that random(0) 
> consistently produces 1, that I looked it up in the reference docs to 
> see if there was an explanation, and some way to fix it to produce 0 
> as I intended it to.
> 
> I do not know in general mathematical principles, what result one 
> would get from random(0).  But I would expect it to be 0.  My mistake 
> for assuming.  (Unless of course, general math principles support my 
> theory :-)
> 
> Any math gurus out there know?
> 
> :-)
> 
> Shari C
> -- 
> --Shareware Games for the Mac--
> http://www.gypsyware.com
> _______________________________________________
> metacard mailing list
> metacard at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/metacard
> 
> 
> 
> 
> Visit us at http://www.clearstream.com
> 
> IMPORTANT MESSAGE
> 
> Internet communications are not secure and therefore Clearstream International does not accept legal responsibility for the contents of this message.
> 
> The information contained in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. If you are not the intended recipient, any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Any views expressed in this e-mail are those of the individual sender, except where the sender specifically states them to be the views of Clearstream International or of any of its affiliates or subsidiaries.
> 
> END OF DISCLAIMER
> 
> 



More information about the metacard mailing list