[SciPy-user] Simple combinatorics with Numpy

Michael mnandris@blueyonder.co...
Tue Oct 21 13:18:52 CDT 2008


On Tue, 2008-10-21 at 12:00 -0500, scipy-user-request@scipy.org 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
>>> comb(6,3)
array(20.000000000000014)

To get the actual samples, there is a recipe in the Python Cookbook, 2nd
edition, p725

-- 
"When you think of the long and gloomy history of man, you will find far
more hideous crimes have been committed in the name of obedience than
have been committed in the name of rebellion". C.P.Snow,
"Either-Or" (1961)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://projects.scipy.org/pipermail/scipy-user/attachments/20081021/fec5ed61/attachment.bin 


More information about the SciPy-user mailing list