Re: question about random generator
pete wrote:
Eric Sosman wrote:
Peter Nilsson wrote:
Eric Sosman wrote:
...
The rand() function generates uniformly distributed
integers in the range 0 <= rand() <= RAND_MAX <= 32767.
ITYM: 0 <= rand() <= RAND_MAX, where RAND_MAX >= 32767
Indeed, yes, that is exactly and precisely what I,
of course, meant. (Blbbbpppfft -- I *hate* when I do that.
Does "pseudo-random" mean the same thing as "uniformly distributed" ?
No. The Standard doesn't actually guarantee any particular
distribution from rand(). On the DeathStation 9000, rand()
returns 42 every time you call it.
I've always assumed that the Standard doesn't describe the
distribution because doing so would require a lot of fairly
deep mathematics; Knuth devotes thirty-five pages to the topic
"What is a random sequence?" Developing a useful theory of
the randomness of finite sequences is (it seems) no simple
matter -- certainly not a topic for the Standard to explicate.
So the Standard just says "pseudo-random," and we all understand
that it means "sort of uniform-ish in a sort of hand-waving way,
noodge noodge wink wink."
Anyhow, that's how I've imagined the committee's intent.
The Rationale sheds no further light on the matter, either.
--
Eric Sosman
esosman@xxxxxxxxxxxxxxxxxxx
.
Relevant Pages
- Re: question about random generator
... The Standard doesn't actually guarantee any particular ... On the DeathStation 9000, rand() ... > distribution because doing so would require a lot of fairly ... IMHO, to have a footnote that mentions a uniform distribution, however ... (comp.lang.c) - Re: Random Number Generation Dialog Box
... > distribution. ... A help search tells me about what looks like a wonder dialog ... Be aware, however, that the ATP's pseudorandom number generator is not ... XL01's RAND() ... (microsoft.public.mac.office.excel) - Re: random integer
... that could throw off the distribution: ... } while (y>= cutoff); ... Unless rand() behaves funny, this should usually be pretty efficient. ... and y lies in one of those sub-intervals. ... (comp.programming) - Re: Random Numbers?
... It is likely to overflow, ... The distribution is uneven for large values of. ... To get the range x to y, inclusive, the following approximates even ... y, is, in general, r:, assuming that the distribution or rand() is ... (comp.lang.c) - Re: question about random generator
... >> random number that follow a normal distribution N? ... > rand() function which returns an int ranging from 0 to RAND_MAX. ... > no random number functions in ISO C which return a floating point value. ... If you care about the quality of your random numbers, my advice would ... (comp.lang.c) |
|