|
|
Am 25.08.2010 18:38, schrieb Anthony D. Baye:
>> First, note that rand() /is/ uniformly distributed, in the interval 0 to
>> RAND_MAX (which, BTW, is typically 32767, but you shouldn't rely on that).
>
> this has not been my experience. printing the result of one million calls to
> rand() gives numbers up to ten digits long, but I've never seen a result less
> than six digits in length. If every result were equally likely, there should be
> SOME lower numbers in the batch, shouldn't there?
Okay, let me rephrase that:
"... rand() /is/ _supposed_ to be uniformly distributed..."
According to ANSI-C standard, the actual implementation of rand() is
implementation-specific, and is known to be poor in typical
implementations. The maximum number returned - RAND_MAX - is
implementation-specific as well, and is specified to be at least 32767.
According to Microsoft documentation, their C runtime library has
RAND_MAX=32767, though I haven't actually bothered to test it.
Post a reply to this message
|
|