numpy permutations with replacement

Chris Rebert clp2 at rebertia.com
Mon Apr 13 13:13:19 CEST 2009


On Mon, Apr 13, 2009 at 4:05 AM, skorpio11 at gmail.com
<skorpio11 at gmail.com> wrote:
> I am trying to generate all possible permutations of length three from
> elements of [0,1]. i.e in this scenario there are a total of 8
> distinct permutations:
>
> [0,0,0]
> [0,0,1]
> [0,1,0]
>    .
>    .
>    .
> [1,1,1]
>
>
> Does numpy define a function to achieve this ?

No idea, but the Python standard library already has this covered with
itertools.permutations()
[http://docs.python.org/library/itertools.html].

Cheers,
Chris

-- 
I have a blog:
http://blog.rebertia.com



More information about the Python-list mailing list