Re: A Friday Python Programming Pearl: random sampling

2010-05-29 Thread Mark Dickinson
On May 29, 3:43 pm, Bryan wrote: > Mark Dickinson wrote: > > N.B.  I don't claim any originality for the algorithm; only for the > > implementation: the algorithm is based on an algorithm attributed to > > Robert Floyd, and appearing in Jon Bentley's 'Programming Pearls' book > > Actually it is th

Re: A Friday Python Programming Pearl: random sampling

2010-05-29 Thread Bryan
Mark Dickinson wrote: > N.B.  I don't claim any originality for the algorithm; only for the > implementation: the algorithm is based on an algorithm attributed to > Robert Floyd, and appearing in Jon Bentley's 'Programming Pearls' book Actually it is the sequel, /More Programming Pearls/. > (thou

Re: A Friday Python Programming Pearl: random sampling

2010-05-29 Thread Xavier Ho
On 29 May 2010 06:44, Mark Dickinson wrote: > But I was struck by its beauty and > simplicity, and thought it deserved to be better known. > Wow, that took me at least 2 minutes to see its beauty as well. Nice find, Mark. Thanks for sharing. (Also, it's nice to see another SOer on Python-List a

A Friday Python Programming Pearl: random sampling

2010-05-28 Thread Mark Dickinson
For a lazy Friday evening, here's a Python algorithm that seemed so cute that I just had to share it with everyone. I'm sure it's well known to many here, but it was new to me. Skip directly to the 'sample2' function to see the algorithm and avoid the commentary... Suppose that you want to selec