Pick the i-th word (replacing the previously chosen word, if any) with probability 1/i? (numbering of words starts from 1 instead of 0).
An interesting related problem is if you are only allowed one pass through the data how would you randomly choose one word.
--
--
Regards,
KC
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe