>  Docs Center  >  Libraries  >  Coyote  >  CGRANDOMINDICES
Libraries

CGRANDOMINDICES

CGRANDOMINDICES
  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 <http://www.idlcoyote.com/code_tips/randomindex.html>`
  on the IDL newsgroup.
 

Categories


    Utilities
   

Params


    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


      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

History


    Change History::
        Written, 22 December 2011 from an algorithm by JD Smith. David W. Fanning.

Copyright


    Copyright (c) 2011, Fanning Software Consulting, Inc.



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us