View Single Post
Old 05 January 2012, 23:22   #10
Thorham
Computer Nerd
 
Thorham's Avatar
 
Join Date: Sep 2007
Location: Rotterdam/Netherlands
Age: 47
Posts: 3,788
Quote:
Originally Posted by Ed Cruse View Post
Then wouldn't the method I described be as bias free as the RNG. It's real simple, do an RNG from 0-11 and pick from the list and then mark that entry as picked. Then run the generator again and use that pick unless it's already been picked in which case run the generator again until you get an unpicked entry. Now obviously when you get to the end of the list the generator will get run a lot because the probability of an entry having already been pick is high. There should be no bias though.
I really don't know. It has to be tested But re-picking numbers doesn't seem to be a problem (although these things can be tricky to judge properly).

I just listed Durstenfelds algorithm because it's the most efficient. It allows you to shuffle any kind of array in-place, and it only has to re-pick a random number once in a while (although for big moduli this will take extra code to handle efficiently). Also, for smaller arrays, it's possible to use a modulus list, making the thing even faster.
Thorham is offline  
 
Page generated in 0.06368 seconds with 11 queries