randSample_cpp function

Random Sampling

Random Sampling

Randomly select records given a probability weight vector prob.

NOTE: This is an internal function used for testing the C++-function randSample which is used inside the C++-function recordSwap().

randSample_cpp(ID, N, prob, IDused, seed)

Arguments

  • ID: vector containing record IDs from which to sample
  • N: integer defining the number of records to be sampled
  • prob: a vector of probability weights for obtaining the elements of the vector being sampled.
  • IDused: vector containing IDs which must not be sampled
  • seed: integer setting the sampling seed