Subtract with carry
Subtract-with-carry is a pseudorandom number generator of the lagged Fibonacci type introduced by George Marsaglia and Arif Zaman in 1991.[1]
Algorithm
Sequence generated by the subtract-with-carry engine may be described by the recurrence relation:
where .
Constants S and R are known as the short and long lags, respectively.[2] Therefore, expressions and correspond to the S-th and R-th previous terms of the sequence. S and R satisfy the condition . Modulus M has the value , where W is the word size, in bits, of the state sequence and .
The subtract-with-carry engine is one of the family of generators which includes as well add-with-carry and subtract-with-borrow engines.[1]
It is one of three random number generator engines included in the standard C++11 library.[3]
References
- A New Class of Random Number Generators, George Marsaglia and Arif Zaman, The Annals of Applied Probability, Vol. 1, No. 3, 1991
- subtract_with_carry_engine Class, Microsoft Visual Studio 2015
- std::subtract_with_carry_engine, cppreference.com