quote:
Original post by Anonymous Poster
Strike three! I'm out! Didn't understand a word of that sentence above.
Why wouldn't the (rand() / RAND_MAX) * anything work?
rand () returns an int between 0 and RAND_MAX-1, inclusive.
RAND_MAX is an integer.
Any integer divided by an integer that is greater than it produces zeros.
That statement will only produce zeros.
I just didn't want to come right out and say it, so I tried to insert a little information theory humor. Entropy is a way of measuring the amount of information in a process (the more random, the more information). I was going to say a zero-mean absolutely deterministic process, but I thought that would have been giving it away.
Only took a couple of days for someone to notice. *sigh*
EDIT: rand actually goes up to RAND_MAX, not RAND_MAX-1. So if you use the above algorithm, you will get a value of (multiplier) 1 time in every 32768 times with a uniform rand function, and 0 the rest of the time. Therefore it's not zero-mean, but it still has very low entropy. Sorry for the mix-up.
Edited by - Stoffel on August 15, 2001 4:31:51 PM