[Numpy-discussion] is there an efficient way to get a random set of subsets/combinations?
Christopher Jordan-Squire
cjordan1@uw....
Mon Feb 20 23:17:19 CST 2012
If you're using numpy 2.0 (the development branch), the function
numpy.random.choice might do what you're looking for.
-Chris
On Mon, Feb 20, 2012 at 8:35 PM, Yaroslav Halchenko
<lists@onerussian.com> wrote:
> Hi to all Numeric Python experts,
>
> could not think of a mailing list with better fit to my question which might
> have an obvious answer:
>
> straightforward (naive) Python code to answer my question would be
> something like
>
> import random, itertools
> n,p,k=100,50,10 # don't try to run with this numbers! ;)
> print random.sample(list(itertools.combinations(range(n), p)), k)
>
> so the goal is to get k (non-repeating) p-subsets of n, where n and p
> prohibitively large to first populate the full set of combinations.
>
> Thank you in advance ;-)
> --
> =------------------------------------------------------------------=
> Keep in touch www.onerussian.com
> Yaroslav Halchenko www.ohloh.net/accounts/yarikoptic
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list