Hi,
is there an existing function in C like rand(), but which creates real
random numbers?
newatC
Printable View
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?
hint: humans are far worse random number generators than computers have the potential to be...Quote:
Originally Posted by fnoyan
>> 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.
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]
Hi,
thank you for your answers, and thank you for the link Salem.
newatC