A
aegis
is there any trickery that can be done
with rand() so that it generates a uniformly
distributed sequence?
Suppose that I want any thing in the range
m..n (inclusive) to be generated such that
I never have a recurrence of a number.
I could build a table I suppose as I call
rand and any number in that table already
can be ignored. So I can sit and call rand
until I get the desired number that is not yet
in the list.
So if I want (inclusive) 0..3
then imagine rand() % (3 + 1) working as desired.
I consider the use of a table to keep track to be
a pretty idiotic approach though. Anyone have
another way of doing it, up their sleeve?
with rand() so that it generates a uniformly
distributed sequence?
Suppose that I want any thing in the range
m..n (inclusive) to be generated such that
I never have a recurrence of a number.
I could build a table I suppose as I call
rand and any number in that table already
can be ignored. So I can sit and call rand
until I get the desired number that is not yet
in the list.
So if I want (inclusive) 0..3
then imagine rand() % (3 + 1) working as desired.
I consider the use of a table to keep track to be
a pretty idiotic approach though. Anyone have
another way of doing it, up their sleeve?