comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Random selection of pairs
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Random selection of pairs [message #51246 is a reply to message #51244] Sat, 11 November 2006 20:30 Go to previous messageGo to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
Kenneth P. Bowman wrote:
> It will be much simpler, and probably much quicker, to read all
> of the pairs and then pick 100 randomly, like this script named
> select_random:
>
> x = findgen(2, 1000) ;create fake lon-lat data
> r = RANDOMU(seed, 1000) ;generate random numbers
> j = (SORT(r))[0:9] ;find indices of 10 smallest numbers

Yes, I think this is the way to do it.

It won't help here with only 1000 elements, but I have a routine to get
the indices of the n smallest (or largest) values in an array. It uses
HISTOGRAM and REVERSE_INDICES instead of the SORT in the line

j = (SORT(r))[0:9]

The article describing it is at:

http://michaelgalloy.com/2006/06/02/finding-the-n-smallest-e lements-in-an-array.html


Mike
--
www.michaelgalloy.com
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Keystrokes While IN a Graphics Window?
Next Topic: colorbar positioning in postscript

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 12:11:46 PDT 2025

Total time taken to generate the page: 0.72273 seconds