python & mathematical methods of picking numbers at random

Bart Nessux bart_nessux at hotmail.com
Thu Jan 15 14:33:18 EST 2004


I am using method 'a' below to pick 25 names from a pool of 225. A 
co-worker is using method 'b' by running it 25 times and throwing out 
the winning name (names are associated with numbers) after each run and 
then re-counting the list and doing it all over again.

My boss thinks that 'b' is somehow less fair than 'a', but the only 
thing I see wrong with it is that it is really inefficient and ugly as 
it's doing manually what 'a' does automatically, other than that I think 
the outcome of both methods (25 unique winners from a pool of 225) are 
the same. Anyone disagree with that and if so, please demonstrate how 
'b' isn't as fair as 'a'

count = len(list_of_potential_winners)

a = random.sample(range(count), 25)

b = random.sample(range(count), 1)

Thanks!
Bart




More information about the Python-list mailing list