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

Home » Public Forums » archive » Re: IDL function randperm?
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: IDL function randperm? [message #36158 is a reply to message #36157] Wed, 20 August 2003 06:52 Go to previous messageGo to previous message
rigby is currently offline  rigby
Messages: 16
Registered: September 1995
Junior Member
This is what I use to randomly reorder an array, stripped down to its
essentials.I stole the idea from the old RSI newsletter many years
ago.

FUNCTION Randomize, list, seed
; LIST is the array to be randomized
; SEED is the random number generator seed

n = n_elements(list)
return, list[sort(randomu(seed,n))]

end ;; Randomize

IDL> seed = 1
IDL> print, Randomize( indgen(5), seed)
1 0 3 2 4

Note that randomu(), and thus Randomize(), returns SEED as a
36-element long array, tho' you can initialize it with a scalar.

--Wayne

Amara.Graps@ifsi.rm.cnr.it (Amara Graps) wrote in message news:<Amara.Graps-2008031259130001@amaramac.ifsi.rm.cnr.it>...

> I wonder if any of you have an IDL function that gives a
> random permutation of an array index, or know of a
> straightforward way to compute it?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Two questions (about Mpeg and Networking)
Next Topic: bug in CONTOUR

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

Current Time: Fri Oct 10 04:57:34 PDT 2025

Total time taken to generate the page: 1.36090 seconds