.comment-link {margin-left:.6em;}

December 28, 2006

 

NXT Random Number Generator

It's official. The NXT's random number generator is not very good.

The first test was with my Die Rolling Program. I noticed tonight while showing it off that the first ten rolls or so were all even numbers. Then the next five or so were all odd numbers.

So then I saw a comment somewhere about testing randomness but choosing two numbers and plotting a point at the X, Y location on the display. Do that a few thousand times. If you see a pattern, the random number generator is not very random.

Well, it only takes five blocks to write such a test. And the results are not good for the NXT random number generator. The display ends up looking like a grid of squares, instead of filling up randomly and (eventually) completely.

Has anyone found a way to improve the randomness of the Random Number block?

Comments:
This is an interesting test. I tried a couple things similar to what you tested. What were your bounds for the x and y random numbers. When I first set y as 0 to 63 and x as 0 to 99 (the screen dimensions) I got behavior as you described. A pattern of 5 by 5 pixel boxes with a single pixel in the center of each box. There was some randomness, but there was a definite pattern. When I changed the outputs to 0 to 100 for each I got a much more random result. It appears that if you set the range such that the number of valid numbers in the range is even then the output is not random (i.e. 10 to 19, 10 valid outputs). If the range is chosen to have an odd number of outputs then the result is much more random (i.e. 10 to 20, 11 valid outputs). Let me know if you see the same thing.
 
Hi, Brian. I did about the same numbers - 0-60 and 0-100 I think.

I posted a "bug" on the nxtasy blog (which I can no longer log into the past couple days, for some reason).
 
Hi, I did another test: a random number 0-1 10000 times x 20 times, I summed the numbers and the average deviation was %+2, the major deviation was %+4.
 
"Has anyone found a way to improve the randomness of the Random Number block?"

Do you mean in NXT ? or work around for these problems in general ??
 
In the NXT.
 
The reason there is a pattern is that all random number generators on computers are pseudo-random,and because of this if you do not change the seed you will always have the same string of random numbers, sadly NXT-G does not provide this option.
 
Yes, without changing the seed you will get the same sequence. I realized that. But they should have either provided a way to seed the generator, or done that automatically, with the current time (e. g., seconds since last re-boot).
 
so, the nxt 2.0 does not allow you to input a seed for the generator?
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?