.\
cgrandomindices.pro
top cgRandomIndices
Utilities
result = cgRandomIndices(length, number [, SEED=long])
This function returns random indices without replacement. You can, for example, select 100 random, unique indices from a vector of 10000 random indices.
The program uses an algorithm offered by JD Smith on the IDL newsgroup.
Parameters
- length in required type=long
The number of random values to be considered in the selection process. In other words, the length of the selection vector.
- number in required type=long
The number of unique, random indices you want the function to return out of the selection vector.
Keywords
- SEED in optional type=long
The seed for the random number generator, RandomU. This is also an output variable, which you should use as the input to the next cgRandomIndices call, if you need to do several random selections very quickly in a program.
Examples
To select 10 random indices from a list of 100:
indices = cgRandomIndices(100, 10, SEED=seed)
Print, indices
7 13 20 21 32 44 50 66 80 93
Author information
- Author:
FANNING SOFTWARE CONSULTING:
David W. Fanning 1645 Sheely Drive Fort Collins, CO 80526 USA Phone: 970-221-0438 E-mail: david@idlcoyote.com Coyote's Guide to IDL Programming: http://www.idlcoyote.com
- Copyright:
Copyright (c) 2011, Fanning Software Consulting, Inc.
- History:
Change History:
Written, 22 December 2011 from an algorithm by JD Smith. David W. Fanning.
File attributes
Modification date: | Fri Mar 27 11:07:39 2015 |
Lines: | 118 |
Docformat: | rst rst |