|
extracting a random subset of a vector: msg#00079python.numeric.general
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> |
|---|---|---|
| Previous by Date: | Re: rebin (corrected): 00079, Tim Hochberg |
|---|---|
| Next by Date: | Help req: IDL --> Numeric/numarray: 00079, RJ |
| Previous by Thread: | RE: rebini: 00079, Nadav Horesh |
| Next by Thread: | Re: extracting a random subset of a vector: 00079, Chris Barker |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |