Re: randomize array
Dr John Stockton wrote on 02 apr 2004 in comp.lang.javas cript:[color=blue]
> That loop is done five times, and each time it generates one of five
> numbers. The total number of possible routes, all equally probable, is
> thus 5^5.
>
> There are 5! possible orders for the five items.
>
> 5^5 is not an integer multiple of 5! ; therefore, the method cannot
> generate all 5! orders with exactly equal probability.
>[/color]
This can be, but the increase in speed is significant, because you do not
have to search and repeat for uniqueness.
Shuffling is a good option, if you tolerate a not exact randomness.
The quality increases with repeating the shuffle, not necessary in this
case, I think, unless one of the paying(!) target URL's complains.
=============== =
btw, can you give an exact value to the deviation of the chance of having
one URL being on place 1 from 20% in the case of n=5. Is this dependent
on the initial position ?
5 x 5 = 25
1 x 2 x 3 x 4 x 5 = 120
.... [sorry I give up]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dr John Stockton wrote on 02 apr 2004 in comp.lang.javas cript:[color=blue]
> That loop is done five times, and each time it generates one of five
> numbers. The total number of possible routes, all equally probable, is
> thus 5^5.
>
> There are 5! possible orders for the five items.
>
> 5^5 is not an integer multiple of 5! ; therefore, the method cannot
> generate all 5! orders with exactly equal probability.
>[/color]
This can be, but the increase in speed is significant, because you do not
have to search and repeat for uniqueness.
Shuffling is a good option, if you tolerate a not exact randomness.
The quality increases with repeating the shuffle, not necessary in this
case, I think, unless one of the paying(!) target URL's complains.
=============== =
btw, can you give an exact value to the deviation of the chance of having
one URL being on place 1 from 20% in the case of n=5. Is this dependent
on the initial position ?
5 x 5 = 25
1 x 2 x 3 x 4 x 5 = 120
.... [sorry I give up]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Comment