# randSample

## PURPOSE

Generate values sampled uniformly without replacement from 1:n.

## SYNOPSIS

function r = randSample( n, k, isArray )

## DESCRIPTION

     Generate values sampled uniformly without replacement from 1:n.

     If n is an integer, samples k values from 1:n without replacement. If n
     is an array, samples k values without replacement from n. This function
     implements much of the same functionality as randsample.m in the
     Statistics Toolbox.

     USAGE
      r = randSample( n, k, [isArray] )

     INPUTS
      n           - specifies sampling source (if array) or range (if scalar)
      k           - the number of samples to draw
      isArray     - [0] if true treat n as an array (even if has single elt)

     OUTPUTS
      r           - k uniformly generated random samples

     EXAMPLE
      r = randSample( 10, 5 )
      r = randSample( [ 5 6 8 9 32 45 ], 2 )

     See also randperm

     Piotr's Image&Video Toolbox      Version 2.50
     Copyright 2010 Piotr Dollar.  [pdollar-at-caltech.edu]
     Please email me if you find bugs, or have suggestions or questions!
     Licensed under the Lesser GPL [see external/lgpl.txt]

## CROSS-REFERENCE INFORMATION

This function calls:

This function is called by:

- kmeans2 Fast version of kmeans clustering.
- pca Principal components analysis (alternative to princomp).
- rbfComputeBasis Get locations and sizes of radial basis functions for use in rbf network.
- clusterMontage Used for visualization of clusters of images and videos.
- jitterImage Creates multiple, slightly jittered versions of an image.