I wish to generate psuedo-random numbers/permutations that 'occupy' a full period or full cycle within a range. Usually an 'Linear Congruential Generator' (LCG) can be used to generate such sequences, using a formula such as:
X = (a*Xs+c) Mod R
Where Xs is the seed, X is the result, a and c are relatively prime constants and R is the maximum (range).
(By full period/full cycle, I mean that the constants can be chosen so that any X will occur only once in some random/permuted sequence and will be within the range of 0 to R-1 or 1 to R).
LCG almost meets all of my needs. The problem I have with LCG is the non-randomness of the odd/even result, ie: for a seed Xn, the result X will alternate odd/even.
Questions:
Does anybody know how to create something similar that will not alternate odd/even?
I believe that a 'Compound LCG' could be built, but I don't have details. Can somebody give an example of this CLCG?
Are there alternative formulas that might meet the details above and constraints below?
Constraints:
- I want something based on a simple seed-based formula. ie: to get the next number, I provide the seed and get the next in 'random number' in the permuted sequence. Specifically, I cannot use pre-calculated arrays. (See next points)
- The sequence absolutely has to be 'full period/full cycle'
- The range R could be several million or even 32bit/4 billion.
The calculation should not suffer overflow and be efficient/fast, ie: no large exponents or dozens of multiplies/divides.
Sequence does not have to terribly random or secure - I do not need cryptographic randomness, just 'good' randomness or apparent randomness, without odd/even sequences.
Any thoughts appreciated - thanks in advance.