Hi,
is there an existing function in C like rand(), but which creates real
random numbers?
newatC
This is a discussion on real random numbers within the C Programming forums, part of the General Programming Boards category; Hi, is there an existing function in C like rand(), but which creates real random numbers? newatC...
Hi,
is there an existing function in C like rand(), but which creates real
random numbers?
newatC
Well, since computers cannot think like any human being, "random numbers" are always depend on something (like clock cycles for example!)
You can use srand() for better results.
http://faq.cprogramming.com/cgi-bin/...&id=1043284385
By real - you mean really random, cannot be predicted in advance using any known algorithmic technique?
Or real as in a floating point number between 0.0 and 1.0 say?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
hint: humans are far worse random number generators than computers have the potential to be...Originally Posted by fnoyan
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
>> Or real as in a floating point number between 0.0 and 1.0 say?
I think he means that. You could make a random function which multiplies a few random numbers together and returns the result. You could even use rand() to get the number of times things are multiplied! Oh, the possibilities!
hmm... wouldnt multiplication of (pseudo-)random numbers change the distribution? For example, there is a probability of 1/6 to get a given number from rolling a 6 sided die, but rolling the die twice (or using two dice) would not lead to a probability of 1/36 for each possible number.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
no it doesn't, it creates a weighted randomness... that's why 7 is a 'lucky' number.
[edit]Code:2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9 5 6 7 8 9 10 6 7 8 9 10 11 7 8 9 10 11 12 Ocurrances: 1 has 0 possibilities 2 has 1 possibilities 3 has 2 possibilities 4 has 3 possibilities 5 has 4 possibilities 6 has 5 possibilities 7 has 6 possibilities
"no it doesn't" was said in agreement to you laser
[/edit]
Last edited by major_small; 09-01-2006 at 01:10 PM.
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
Hi,
thank you for your answers, and thank you for the link Salem.
newatC