# Statistical tests for PRNG that generates a sequence which is not binary

I have already asked this question on crypto.stackexchange but I think here is the appropraite site for this.

Is there a pratical application to PRNG that generates a sequence which is not a binary one? A ternary, quaternary sequence, for instance. If so, how can we test this? Is there any alternative test suite, like NIST test suite in order to test the randomness for non-binary sequences? For example, what if I generate a sequence in modulo 255 and then use it to encrypt an image in one-time pad manner via adding the values of pixels by the generated sequence in modulo 255 ?

• (1) By expressing values mod 255 in base 2, any sequence of them is equivalent to a sequence of bits eight times as long. A similar method is used to convert the outputs of other PRNGs to sequences of bits. (2) Concerning practical applications: statistics makes frequent use of PRNGs that are not binary: perhaps the commonest ones generate uniform floats in the interval $[0,1)$. – whuber Feb 7 '18 at 14:34
• @whuber Actually, (1) is the first thing that I thought, however I cannot be sure if it is a proper method. Let me express why. Consider a modulo, not a power of 2, say 3. The appropriate way representing $0,1,2$ is $00,10,11$ for the sake of respecting the frequency of zeros and ones. However, if we take all $2−$tuples in modulo 3 and covert them to binary we have $0000,0010,0011,1000,1010,1011,1100,1110,1111$. Isn't it a handicap that absence of some binary $4−$tuples as $0111$ for instance ? – faith Feb 8 '18 at 11:46
• Yes, that's correct. One solution is to take a very long string of values modulo 3, interpret that as an enormous integer in base 3, convert that to base 2, and finally drop the first few significant digits. Since the conversion can be done with a (simple) sequential algorithm, it isn't actually necessary to create and process this string all at once. – whuber Feb 8 '18 at 14:07