Hi nb-,
Thanks for the reply.
It seems the native VB RND function only has a period of 16,777,216 which is ridiculous.
That is a given, since the Excel random number generator uses Single Precision (32 bit) Math. Back in the day, I rarely used the random number generators supplied by the compilers I used, but used a custom algorithm (long since lost by me), which had been known to give excellent pseudo-random results.
I am however still at a loss as to what the cause of the repetition I am getting is? E.g. in my example above for 10,000 numbers I essentially get 2,000 'random' numbers each repeated 5 times.
I ran your code exactly as written, with the addition of a comparison loop after the 'Quick Sort'. Each time I ran the code, I got 10,000 unique numbers. I also 'eyeball tested' goodness of fit by counting the numbers in certain ranges
and putting the results in rows 1 to 100. Without any statistical tests, the numbers seemed evenly distributed as I would expect.
----------------
In the above code, I think the Randomize statement is unnecessary, as you are reseeding the values during each random number access.
Lewis
Bookmarks