Personal IDL library for M. Galloy

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


includes main-level program

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



nValues in required type=long

size of array to choose indices from

nIndices in required type=long

number of indices needed


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

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



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, ind 2 4 7 IDL> print, r[ind] 0.250856 0.135338 0.0753110

File attributes

Modification date: Wed Sep 14 10:27:47 2011
Lines: 71
Docformat: rst rst
Personal library of Michael Galloy
Contact me if you have enhancement requests or bug fixes.