Simple Random Number Generator

1 view
Skip to first unread message

Ludovicus

unread,
Aug 17, 2009, 6:02:45 PM8/17/09
to Open Mathematics Forum
I want to know your opinion on this RNG:

1.- Fix the number D of digits desired for the integer random number.

2.- Take an integer R with 7 or more digits and other integer k of 3
digits.

3.- k = k +1 : R = R + k

4.- Multiply it by 4 and substract 1.

5.- Extract its square root Q with more than D decimals.

6.- Take the fractional part of Q.

7.- Multiply it by 10^D

8.- Take its integer part : This is the random number R of D or less
digits.

9.- Goto instruction 3

Remarks.
By the instruction 3 . this RNG permits that the numbers be repeated
without enter in a loop . Also permits the aparition of zero.

By instruction 4, the square root will be irrational ever.

I subjected this method to the clasical statistical tests and it
showed consistence.

Ludovicus

unread,
Aug 19, 2009, 4:32:58 PM8/19/09
to Open Mathematics Forum
CORRECTED VERSION BY THE AUTHOR:

1.- Fix the number D of digits desired for the integer random number.

2.- Take an integer S as seed with L digits (L >= 7)
Take another integer k with 3 or more digits


3.- k = k + 7 : S = S + k


4.- Multiply it by 4 and substract 1.


5.- Extract its square root Q with L or more decimals.


6.- Take F = fractional part of Q.


7.- Multiply F by 10^D


8.- Take its integer part : This is the random number R with D or
less
digits. That is: R = INT(10^D*F)

9.- Multiply F by 10^L and take the integer part. That is: S = INT
(10^L*F)


10.- Go to instruction 3

larryh...@telus.net

unread,
Aug 19, 2009, 9:53:13 PM8/19/09
to Open Mathematics Forum
I think the output (a sequence of integers with D digits) would
perforce be periodic, because S mod 10^something is periodic. But the
period would be huge.

Looks pretty good to me though, except that the square root operation
is relatively slow.
Reply all
Reply to author
Forward
0 new messages