generateSeedVectors {dqrng}R Documentation

Generate seed as a integer vector


Generate seed as a integer vector


generateSeedVectors(nseeds, nwords = 2L)



Integer scalar, number of seeds to generate.


Integer scalar, number of words to generate per seed.


Each seed is encoded as an integer vector with the most significant bits at the start of the vector. Each integer vector is converted into an unsigned integer (in C++ or otherwise) by the following procedure:

  1. Start with a sum of zero.

  2. Add the first value of the vector.

  3. Left-shift the sum by 32.

  4. Add the next value of the vector, and repeat.

The aim is to facilitate R-level generation of seeds with sufficient randomness to cover the entire state space of pseudo-random number generators that require more than the ~32 bits available in an int. It also preserves the integer nature of the seed, thus avoiding problems with casting double-precision numbers to integers.

It is possible for the seed vector to contain NA_integer_ values. This should not be cause for alarm, as R uses -INT_MAX to encode missing values in integer vectors.


A list of length n, where each element is an integer vector that contains nwords words (i.e., 32*nwords bits) of randomness.


Aaron Lun


generateSeedVectors(10, 2)

generateSeedVectors(5, 4)

[Package dqrng version 0.3.0 Index]