On Tue, 24 Jan 2006 18:47:01 +0200, Steven Macintyre wrote: > Hi all, > > I need to retrieve an integer from within a range ... this works ... below > is my out puts ... it just does not seem so random ...
You are choosing from six values. You should expect each value _about_ 17% of the time, in the long-term. On your tiny sample of 17 samples, you get this: 7 3 3 4 3 4 7 7 7 5 6 3 8 8 5 3 4 3 occurs five times or 29% 4 occurs three times or 18% 5 occurs two times or 12% 6 occurs one time or 6% 7 occurs four times or 23% 8 occurs two times or 12% Looks pretty random to me. With only 17 trials, it would be a major miracle to get near 17% for every number. If you actually got something like this: 5 3 4 5 8 4 7 5 6 8 6 3 6 7 4 3 7 the odds are VERY strong that it is not really random. For one thing, it is too good to be true. For another thing, there are no repeated values. The chances of there being no repeated values is very small indeed. > Is there perhaps a suggestion out there to create a more random int ...? 23 is the most random int. Perhaps you should use that. But all joking aside, the random number generator used by Python is one of the best in the world. What is at fault is your intuition about what random numbers should look like, not the random number generator. -- Steven. -- http://mail.python.org/mailman/listinfo/python-list