[Math] Generate random number based on a certain pattern and able to test against the pattern

pattern recognitionrandom

I have very little idea about random numbers and patterns, so I am not sure whether this is actually possible or not.

I want to generate random numbers, that will follow a fixed pattern (perhaps this itself breaks the definition of 'randomness'?). Say for example, a number whose every alternate digit will be even/odd, like 123456. For such a pattern, say of 30 digits, I want to generate random numbers. And when generated, I want to verify the number against the pattern (so here I will verify whether the random number generated has every alternate digit as odd/even, if so, then it succeeds the check)

Is there any way to develop a fairly complicated (and if I may, notoriously difficult to find out by anybody else) pattern and generate random numbers in that pattern?

Best Answer

Yes, the problem is much more with defining a pattern you like than with the random numbers. Taking your alternate even/odd example, each digit has five choices, so you can just generate a random number from $0$ through $4$ for each digit. If the digit is supposed to be an even one, double it. If the digit is supposed to be odd, double it and add $1$. Now you have a number with digits alternating as desired that is randomly chosen among all the numbers that satisfy your criterion.

The problem you are seeing is that this is too easy a pattern for someone to identify. Choosing an appropriately hard pattern is not really a mathematical problem. You might just pick some ten digit prime number $p$ and have your pattern be multiples of that. When you want a random number thirty digits long, generate a random between $0$ and $10^{30}/p$, multiply by $p$ and report the result. Again your reported number will be random in the acceptable space. Clearly there are many patterns that can be defined.

Related Question