Re: 32-bit random numbers
- Posted by Tommy Carlier <tommy.carlier at pandora.be> Jul 03, 2004
- 590 views
Juergen Luethje wrote: > Hi, this function can not take a big 32-bit integer atom as argument. > If n > 2*#3FFFFFFF, then (n - #3FFFFFFF) > #3FFFFFFF, that means the > argument to the first call of rand() will be too big, and Euphoria > aborts with a syntax error. > > Also, I want the rand32() function to behave like Euphoria's built-in > rand() function. That means, the returned values must have a uniform > distribution. Are you sure, that the sum > rand(n - #3FFFFFFF) + rand(#3FFFFFFF) > is uniformly distributed? > > Sorry, I don't have a statistical test for this at hand ATM. You're totally right. I just typed in some function here, without really thinking about it a lot. I just wanted to show how easy it would be to create a function that generates 32-bit random numbers. The function I gave was just to push others in the right direction. As Robert already pointed out: the returned values are indeed not uniformly distributed. Instead of adding 2 random integers, a different formula should be used. I'm sure there are enough smart Euphorians to solve this problem. -- tommy online: http://users.pandora.be/tommycarlier Euphoria Message Board: http://uboard.proboards32.com