logo       

extracting a random subset of a vector: msg#00079

python.numeric.general

Subject: extracting a random subset of a vector


Hi all, I have an optimization problem.

I currently use the following code to select a random subset of a rank-1 array:

----------------------------------------------------------

import numarray as NA
import numarray.random_array as RA

N = 1000
M = 100
full = NA.arange(N)
subset = full[RA.permutation(N)][:M]

---------------------------------------------------------

However, it's quite slow (at least with N~40k), and from the hotshot output is looks like it's the indexing, not the permutation, which takes time.
Does anyone have a suggestion on a faster pure-python implementation?

thanks


-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise