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

Home » Public Forums » archive » Re: Random Sampling Without Replacement
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 Sampling Without Replacement [message #72872] Wed, 13 October 2010 09:01 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On 10/13/10 9:46 AM, David Fanning wrote:
> Has anyone coded up an IDL algorithm to do random
> sampling without replacement?
>
> For example, suppose I want to sample values in
> my 2D image. I want, say, 100 values that represent
> individual pixel locations in the image. How can
> I make sure I get 100 unique, but random, locations?

To randomly sample m elements from n elements, I have used this albeit
inefficient technique:

m = 3
n = 100
im = findgen(n) ; input array
arr = randomu(seed, n)
ind = sort(arr)
print, im[ind[0:m-1]] ; m random elements from im

Mike
--
www.michaelgalloy.com
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Official "release" of Coyote and Catalyst Libraries
Next Topic: Re: execute an idl procedure without seeing idl workbench

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

Current Time: Wed Oct 08 15:31:44 PDT 2025

Total time taken to generate the page: 0.00432 seconds