it IS already available!
look at the test_release section, it's from July 3rd, 2011
FW: bad rand generator: distribution/prevalences/periodicity
-
- Posts: 358
- Joined: 01 Oct 2010, 06:37
- Location: Denmark
- Contact:
Re: FW: bad rand generator: distribution/prevalences/periodicity
I don't quite understand the test code, why should it run for 5 minutes? Something like this:
finishes in less than a second... (I have not updated yet, therefore Random().)
Code: Select all
task main(){
DrawCircleType circle;
repeat( 100 ){
circle.Center.X = Random( 100 );
circle.Center.Y = Random( 64 );
circle.Size = 3;
SysDrawCircle( circle );
circle.Size = 5;
SysDrawCircle( circle );
circle.Size = 7;
SysDrawCircle( circle );
}
Wait( 10000 );
}
My blog: http://spillerrec.dk/category/lego/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
RICcreator, an alternative to nxtRICeditV2: http://riccreator.sourceforge.net/
Re: FW: bad rand generator: distribution/prevalences/periodicity
I don't think the program was designed to be a test of the RNG so much as it was just a program that used random numbers - probably as part of a game, I imagine, and it happened to show a less than ideal randomness to the targets displayed on the LCD. I don't think Doc or the original code's author intended to suggest that delaying between calls to the RNG had any bearing on the quality of the numbers it produced.
In any case, I would encourage users of NXC to use the latest enhanced NBC/NXC firmware and the new rand() and srand() functions. If you must continue to use the standard firmware then use Random(n) to generate "good enough" random numbers between 0 and N or use rand() but not with % N as the means for obtaining a random number between 0 and N. Please, do not use Doc's Mersenne Twister implementation to get a random number unless you are running some kind of simulation on your NXT that requires an extremely high quality random number generator.
John Hansen
In any case, I would encourage users of NXC to use the latest enhanced NBC/NXC firmware and the new rand() and srand() functions. If you must continue to use the standard firmware then use Random(n) to generate "good enough" random numbers between 0 and N or use rand() but not with % N as the means for obtaining a random number between 0 and N. Please, do not use Doc's Mersenne Twister implementation to get a random number unless you are running some kind of simulation on your NXT that requires an extremely high quality random number generator.
John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
http://bricxcc.sourceforge.net/
Who is online
Users browsing this forum: No registered users and 4 guests