[Tutor] quickly pulling marbles out of urns

Kent Johnson kent37 at tds.net
Sat May 17 06:15:23 CEST 2008


On Fri, May 16, 2008 at 5:43 PM, Joel Miller <joel.c.miller at gmail.com> wrote:
> I'm looking for a faster way to do the following problem:
>
> I have an urn with many different colors of marbles in it.  I pull one
> out and note the color.  I do not replace it.

You probably know, this is called sampling without replacement. If you
can put all the 'marbles' in a list, here is a promising approach:
http://groups.google.com/group/comp.lang.python/browse_thread/thread/dff9425afdb744e5/6b9a84329c0815d4?lnk=raot

This is probably worth looking at too though I can't understand it at this hour:
http://safari.oreilly.com/0596007973/pythoncook2-CHP-18-SECT-4

Kent


More information about the Tutor mailing list