quantum mechanics...Or radiation |
User inputs are considered random, and so is the noise on the PCI bus, for example. Look at the methods better operating systems use to generate truly random numbers or at least the entropy pool for their generation (and if you really want to argue that they are not truly random, I suggest that you come up with a method to predetermine them)
Your initial problem might be one of the following two: (a) you initialized the RNG before each call to rand(). Don't do this, initialize with srand() only once. (b) you used the numbers in more than one dimension (e.g. generating points (x,y) by calling (rand(), rand())). This might fail, either, since the numbers might be distributed uniformly in only one dimension (the points generated this way then are on hyperplanes in d+1 dimensions, in this case that would be lines). This might not be what you want. (The already mentioned Mersenne Twister generates random numbers uniformly distributed in 624 dimensions; and there are still better (and even simpler) methods around).
The perhaps biggest problem of all is that the standard doesn't say what exactly rand() shall do (the cycle length, the number of independent dimensions etc. aren't specified). So if you want reproducible results, you'll have to use another implementation (there are libraries around, and Knuth's vol. 2 covers the topic of the linear congruential method quite well). This is also a reason why you most likely don't want "real" random numbers: you won't be able to debug your algorithm if the sequence isn't reproducible. However, if you use a PRNG, all you have to do is store the initialization, then you get the same sequence again if required.
As i got, u mean i need to make random function better... any other suggestion ? |
Read about it. You know, in books, articles and papers... (you might want to start with Knuth's vol. 2...). And, as already mentioned, the documentation of an OS entropy pool management. Another source for a not-so-in-depth version would be books on simulation; they usually discuss the topic of PRNGs briefly.
Oh, and being on the topic of really random numbers: I remember a device consisting of a web cam and a lava lamp...