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 #51252 is a reply to message #51246] Sat, 11 November 2006 06:58 Go to previous message
Kenneth P. Bowman is currently offline  Kenneth P. Bowman
Messages: 585
Registered: May 2000
Senior Member
In article <1163249745.126148.50070@h48g2000cwc.googlegroups.com>,
"Julio" <julio@cpa.unicamp.br> wrote:

> I have an array with two columns and a thousand of rows. Each row has a
> pair of latitude and longitude.
>
> Array=float(2, 1000)
>
> -27.3456 -54.6529
> -23.4546 -56.7263
> ... and so on...
>
> I need to retrieve only 100 pairs, randomly. How can I do that?
> Any comments welcome!
> Julio

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
PRINT, j
PRINT, r[j]
FOR k = 0, 9 DO PRINT, x[*,j[k]] ;print 10 random pairs

IDL> @select_random
952 848 497 935 490 678 853 313
365 976
0.000964510 0.00113783 0.00255171 0.00340872 0.00390364 0.00452789 0.00609691
0.00676597 0.0117514 0.0121868
1904.00 1905.00
1696.00 1697.00
994.000 995.000
1870.00 1871.00
980.000 981.000
1356.00 1357.00
1706.00 1707.00
626.000 627.000
730.000 731.000
1952.00 1953.00

Ken Bowman
[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 20:17:58 PDT 2025

Total time taken to generate the page: 0.40007 seconds