| | |
Random numbers...really random??
![]() |
>So is the random number genarator really random
No. The random number generator creates pseudorandom numbers that just look good to a point. Depending on the quality of the generator that point will be quick to arive or not.
>The weird thing is I get 4 like 6 out of 10 times each time I run the program.
That sounds fairly normal. A completely random distribution would have each number equally likely to come up. But pseudorandom numbers aren't quite that good and you can expect slightly skewed results. The best solution is to provide as random of a seed as you can, or replace the random number generator with something better.
No. The random number generator creates pseudorandom numbers that just look good to a point. Depending on the quality of the generator that point will be quick to arive or not.
>The weird thing is I get 4 like 6 out of 10 times each time I run the program.
That sounds fairly normal. A completely random distribution would have each number equally likely to come up. But pseudorandom numbers aren't quite that good and you can expect slightly skewed results. The best solution is to provide as random of a seed as you can, or replace the random number generator with something better.
I'm here to prove you wrong.
•
•
Join Date: Aug 2004
Posts: 49
Reputation:
Solved Threads: 1
Most of the computerized random number generators that I have seen use the last few digits of the time field (milliseconds?) as the seed. Since the start time is going to be random this starts of the random number generator at a random spot in its sequence.
Computer random number generators usually use a formula to derive one number from the previous and eventually cycle through all possible numbers between zero and a fairly large number (usually tens of thousands) but jumping all over the place within the number range during the process. As you usually only want a small number (say up to 100) returned when these tens of thousands of numbers are scaled down they give the appearance of a random sequence of numbers.
The important thing to remember with random number generators is that if you start with the same seed then you will always get the same "random" sequence. That is why you need to use a random number to seed the generator to start with.
Computer random number generators usually use a formula to derive one number from the previous and eventually cycle through all possible numbers between zero and a fairly large number (usually tens of thousands) but jumping all over the place within the number range during the process. As you usually only want a small number (say up to 100) returned when these tens of thousands of numbers are scaled down they give the appearance of a random sequence of numbers.
The important thing to remember with random number generators is that if you start with the same seed then you will always get the same "random" sequence. That is why you need to use a random number to seed the generator to start with.
![]() |
Similar Threads
- Random Numbers (C++)
- Pairs in random numbers (C++)
- Random rotation of a random vector (C++)
- Pascal random numbers are not random (Pascal and Delphi)
- C++ Random Numbers (C++)
- Trying to find a better way to generate random numbers in Dev Pascal (Pascal and Delphi)
- random numbers all different??? (C++)
Other Threads in the Java Forum
- Previous Thread: Need Help with variable initialization
- Next Thread: help with polymorphism and inheritance...getting null values
| Thread Tools | Search this Thread |
account android api applet application array arrays automation awt bidirectional binary birt bluetooth busy_handler(null) chat class classes client code columns component database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer homework html ide image inetaddress inheritance integer intellij j2me java javamicroeditionuseofmotionsensor javaprojects jlabel jme jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile mobiledevelopmentcreatejar monitoring myaggfun netbeans newbie nullpointerexception open-source plazmic print problem program programming project property recursion ria scanner search server set smart sms smsspam sort sourcelabs splash sql sqlite static string subclass support swing testautomation threads tree webservices windows






