Re: Random number generator without duplicates?
Re: Random number generator without duplicates?
- Subject: Re: Random number generator without duplicates?
- From: Ed Stockly <email@hidden>
- Date: Tue, 17 Apr 2001 22:56:38 -0700
>
Brayn>> If your uniform random number generator
>
is not generating every number in
>
the range before repeating, then it does not have a full period, and it is
>
not *exact* in producing values from a true uniform distribution. Good
>
algorithms do this. I have one that's not terribly difficult if you need
>
it.
Bryan, you are misunderstanding the point of this discussion. AppleScript
has a random number command in the the standard additions Osax. It is a
command that will simply generate a single random number every time it's
called and one call has no relation to the next.
It is not a "uniform random number generator" and doesn't try to be, but can
be used as part of an script to create one and several have been posted in
response.
>
> Random order, not random distribution as it's giving us now.
Currently it is now giving us random numbers. Both the distribution and the
order of those numbers are, theoretically, random. Each number having no
relation to the number(s) that preceed or follow. That's all it's designed
to do.
Truly random numbers do repeat because every time any number is generated
every number within the range should have an equal probability of being
generated each time a number is generated.
>
>>"M.S.R.F. Schonewille" <email@hidden> wrote...
>
>>>If you want statistically correct results, make a list of number from which
you want to choose. Shuffle the list and choose from this list ad random.
Delete the chosen element from the list and choose again.
While I agree that this can be the most efficient method...
>
Choosing a random number and ignoring it if it has been chosen before is
>
apparently the most popular approach, but it is incorrect.
While this method may not be the most efficient, I disagree that it is
"statistically incorrect".
>
Note that numbered
>
pieces of paper cannot be chosen from a hat, if these numbers are no longer
>
there. So, yo can't throw them away either. There will be a bias, because the
>
probability of choosing a number that has not been chosen before will be
>
reduced.
Well, this argument illustrates the limitation of the "drawing paper from a
hat" metaphor but not the statistical validity of the algorythm.
When a number is successfully generated, if it had just the same probability
of being selected as any other of the renaming numbers. There is no bias
(beyond what is found in the random number command itself).
>
Mark> wrote:
>
Sorry, but that's not true. You confuse the original sample (which is not
>
random but stochastic) and the random selection from this sample. Compare
>
choosing numbered pieces of papers from a hat. The last number will have a
>
probability P=1 of being chosen, the sequence still being perfectly random.
Again I believe there is confusion here between the command to generate a
single random number and employing that command to generate a
non-duplicating list of random numbers within a certain range.
>
>Michelle>>That's very nice; it's going into my library.
Mine two. With some quick testing I found Chris's shuffle method to be
significantly faster than all the other solutions posted (including my own).
I am curious if the "some item" command in and of iself is statiscally
correct.
ES