Modern IDL by Michael Galloy

API documentation for example code

single page | use frames     summary     class     fields     routine details     file attributes

performance/

mg_sample.pro


top source mg_sample

result = mg_sample(nValues, nIndices [, seed=integer or lonarr(36)])

Get nIndices random indices for an array of size nValues (without repeating an index).

Return value

lonarr(nIndices)

Parameters

nValues in required type=long

size of array to choose indices from

nIndices in required type=long

number of indices needed

Keywords

seed in out optional type=integer or lonarr(36)

seed to use for random number generation, leave undefined to to use a seed generated from the system clock; new seed will be output

Examples

Try:

IDL> r = randomu(seed, 10) IDL> print, r, format='(4F)' 0.6297589 0.7815896 0.2508559 0.7546844 0.1353382 0.1245834 0.8733745 0.0753110 0.8054136 0.9513228 IDL> ind = mg_sample(10, 3, seed=seed) IDL> print, r[ind] 0.250856 0.135338 0.0753110 IDL> print, ind 2 4 7

File attributes

Modification date: Mon Nov 29 18:34:50 2010
Lines: 60
Docformat: rst rst