cmwc.RdGenerates a sequence of pseudo-random numbers using a multiply-with-carry-style recurrence.
cmwc(seed, n, r, bitsize = 32L, a = 7L, c = 4L)Initial seed value for the generator.
Number of pseudo-random values to generate.
Lag parameter for a complementary multiply-with-carry generator. Currently unused in this implementationde
Number of bits used to define the base \(b = 2^{bitsize}\). Defaults to `32`.
Multiplier used in the recurrence. Defaults to `7`.
Initial carry value. Defaults to `4`.
A numeric vector of length `n` containing the generated pseudo-random values.
The generator updates the state using $$x_i = (a x_{i-1} + c) \bmod b$$ where \(b = 2^{bitsize}\). The carry is updated as $$c = \left\lfloor (a x_{i-1} + c) / b \right\rfloor$$
This implementation uses a multiply-with-carry recurrence. Although the function is named `cmwc`, the current implementation does not use the lag parameter `r` and does not apply the complementary transformation commonly used in full CMWC generators.
Wikipedia: Multiply-with-carry pseudorandom number generator. https://en.wikipedia.org/wiki/Multiply-with-carry_pseudorandom_number_generator#Complementary-multiply-withcarry_generators
cmwc(seed = 123, n = 10, r = 5)
#> [1] 865 6055 42385 296695 2076865 14538055 101766385
#> [8] 712364695 691585569 546131688