[SciPy-user] Simple combinatorics with Numpy
Tue Oct 21 16:26:21 CDT 2008
On Tue, Oct 21, 2008 at 11:18 AM, Michael <firstname.lastname@example.org> wrote:
> On Tue, 2008-10-21 at 12:00 -0500, email@example.com wrote:
>> For that, I need to *enumerate* all the possible unordered
>> samples of size 3 that can be drawn from x, i.e.,
>> (1,1,1), (1,1,3), (1,1,5), (1,1,8), (1,3,3), (1,5,5), ...
>> [there are comb(4+3-1,3)=20 different samples]
>>>> from scipy.misc import comb
> To get the actual samples, there is a recipe in the Python Cookbook, 2nd
> edition, p725
I could be wrong, but I don't think the recipe provides what the OP is
requesting. The corresponding docstring would be:
''' take n (not necessarily distinct) items, order is irrelevant '''
which is, noticeably, absent from page 725
More information about the SciPy-user