ELI5: How does a random number generator work?
Pen and paper pseudo-random number generator - Mathematics Stack Exchange
Combinator Pseudo Random Number Generator : factorio
My first scheme project: a pseudo random number generator
Videos
I would use a linear congruential generator. Given a seed $X_n$ it returns $X_{n+1}=aX_n+c \pmod m$ for parameters $a,c,m$. I would then take some low order bits of $X_{n+1}$ as the random number. The calculation is not much even with pen and paper. You could use a relatively small $m$ because you don't need many bits. You would like $m$ to be prime, but if it has some large factors that is probably not so bad for this use. $a$ should be near $\sqrt m$ and coprime to it. You can seed it with $X_0$ being your birthday or some such.
Square roots
One solution would be to use the digits of the square root of a number, such that the square root is not an integer (perfect square).
In that case, the square root should be an irrational number, which is acyclic by definition.
Analyzing this option for the numbers below 100 (with digits for the integer part of the square root plus 100 digits after the dot), I found that the balance between the generated digits is not always fair.
For the actual generated series, the average of the standard deviation was 3.034, with a maximum of 15.044 and a maximum difference between min occurrences and max occurrences of 15 (avg 9.433).
That is, counting the occurrence of each digit on a square root (limited to 100 after the dot) and calculating the standard deviation, then doing that for all non-perfect squares below 100 and taking the average of these results, the result is 3.034.
For the series mod 5 (that is, each element mod 5, for the situations where there are 5 options to choose from), the average standard deviation was 4.139 with a maximum of 7.778 and max diff of 21 (avg 10.178).
For the series mod 2 (true/false), average standard deviation of 5.971, max of 21.213, max diff of 30 (specifically for mod 2 of the digits in the square root of 41, 0 appears 65 times, 1 appears only 35 times), average of 8.444.
I'm not accepting this as the answer for my own question because:
- The analysis above shows the distribution can be quite unbalanced
- Calculating the square root by hand is somewhat expensive; a simpler algorithm would be welcome
- I'm just generally looking for other options