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 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Random Sampling Without Replacement [message #72872] Wed, 13 October 2010 09:01
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
Re: Random Sampling Without Replacement [message #72873 is a reply to message #72872] Wed, 13 October 2010 08:59 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Wayne Landsman writes:

> Read the master? http://tinyurl.com/26edmmq

Ah, my general rule is that I only write articles
on topics I understand. I didn't understand this
then, and I barely understand it now. I'm just
going to have to try harder, I guess. :-)

Thanks!

Cheers,

David


--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Re: Random Sampling Without Replacement [message #72874 is a reply to message #72873] Wed, 13 October 2010 08:53 Go to previous message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
On Oct 13, 11:46 am, David Fanning <n...@dfanning.com> wrote:

>
> Has anyone coded up an IDL algorithm to do random
> sampling without replacement?

Read the master? http://tinyurl.com/26edmmq
  Switch to threaded view of this topic Create a new topic Submit Reply
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 11:35:30 PDT 2025

Total time taken to generate the page: 0.00596 seconds