![]() |
Can anyone explain Random number generation
Hi all,
How are random numbers generated , even using some functions supplied by the programming language? whats the logic behind the random number generation algorithm? |
This is the Knuth PRNG (Pseudo-Random Number generator) that was used in glibc3.1 for Linux, it is reentrant:
:
int |
One of our members has a good explanation :).
http://www.eternallyconfuzzled.com/a..._art_rand.aspx |
short version:
Random numbers aren't really random. They are either "seeded" by a number or by the system time. If seeded by a number, they use calculations to come up with the "random" numbers. If seeded by the system time, they use that to come up with the random numbers. The system time method is better in some cases because it is closer to true randomness. |
Quote:
|
I was clearly referring to 'random numbers' in C programming. Does that clear it up, or am I still incorrect?
|
DaWei's point is that it is possible with the right hardware and libraries to get true random number in C. So just because we are talking about C and random numbers does not mean they are always pseudo-random.
|
You are apparently referring to the PRNG commonly found in the run-time library. This does not preclude one from using C with true random numbers. I'm of the opinion that disseminating flakey information, whether by loose semantics or otherwise, is not a good idea. Again, I'd suggest you follow the earlier link for additional considerations involved in seeding the PRNG with the system's time.
|
Can you show me such a code? Not saying it doesn't exist, but it seems that any code would not be truly random.
"I'm of the opinion that disseminating flakey information, whether by loose semantics or otherwise, is not a good idea." edit: DaWei, I'm all for correct grammar as well, but couldn't you just tell me to shut the hell up if I don't know what I'm talking about? :) Also: I already read everything in the original link. I'm still of the opinion that the numbers you say are "truly random" are only more significantly random than others. While I understand the article's point about distribution, a perfect distribution does not necessarily indicate true randomness. Is that incorrect? |
I didn't mention grammar.
The statement was made that C can use processes that generate truly random numbers. No one mentioned that this will happen with any PRNG, regardless of it's distribution. My view on misinformation remains the same; my expression seemed preferable, at the time of that post, to telling you to just shut the fuck up, read the posts, and maybe resort to Google. |
| All times are GMT -5. The time now is 1:43 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC