25

Irrational numbers like $\pi$, $e$ and $\sqrt{2}$ have a unique and non-repeating sequence after the decimal point. If we extract the $n$-th digit from such numbers (where $n$ is the number of times the method is called) and make a number with the digits as it is, should we not get a perfect random number generator? For example, if we're using $\sqrt{2}$, $e$ and $\pi$, the first number is 123, second one is 471, the next one is 184 and so on.

dkaeae
  • 5,057
  • 1
  • 17
  • 31
Abhradeep Sarkar
  • 377
  • 1
  • 3
  • 6

7 Answers7

50

For any reasonable definition of perfect, the mechanism you describe is not a perfect random number generator.

  • Non-repeating isn't enough. The decimal number $0.101001000100001\dots$ is non-repeating but it's a terrible generator of random digits, since the answer is "always" zero, occasionally one, and never anything else.

  • We don't actually know if every digit occurs equally often in the decimal expansion of $\pi$ or $\mathrm{e}$ (though we suspect they do).

  • In many situations, we require random numbers to be unpredictable (indeed, if you asked a random person what "random" means, they'd probably say something about unpredictability). The digits of well-known constants are totally predictable.

  • We usually want to generate random numbers reasonably quickly, but generating successive digits of mathematical constants tends to be quite expensive.

  • It is, however, true that the digits of $\pi$ and $\mathrm{e}$ look statistically random, in the sense that every possible sequence of digits seems to occur about as often as it should. So, for example, each digit does occur very close to one time in ten; each two-digit sequence very close to one in a hundred, and so on.

David Richerby
  • 82,470
  • 26
  • 145
  • 239
29

It is cryptographically useless because an adversary can predict every single digit. It is also very time consuming.

gnasher729
  • 32,238
  • 36
  • 56
18

The most obvious disadvantage is the unnecessary complexity of PRNG algorithms based on irrational numbers. They require much more computations per generated digit than, say, an LCG; and this complexity typically grows as you go further in the sequence. Calculating 256 bits of π at the two-quadrillionth bit took 23 days on 1000 computers (back in 2010) - a rather prohibitive complexity for an RNG.

Dmitry Grigoryev
  • 532
  • 3
  • 11
7

(updated after many people pointed out that random number generator is not the same thing as a single normal sequence)

If you ask whether you can get a normal sequence out of $\pi$ (i.e., all numbers appear uniformly), then there are several answers on mathoverflow. For example, the answer about Distribution of the digits of Pi says:

...it is believed that $\pi$ is a normal number (~uniform distribution of every digits sequence).

For digit distribution data, see e.g. http://www.eveandersson.com/pi/precalculated-frequencies or https://thestarman.pcministry.com/math/pi/RandPI.html (first 1000 digits):

enter image description here

At mathoverflow, there are also nice answers at:

Ayrat
  • 1,135
  • 1
  • 9
  • 23
3

In general, this approach does not work: "randomness" does not mean that you get a lot of different digits, but there are other aspects as well. For example, a classic test is to see if all two-digit, or three-digit etc. combinations occur with the same frequency. This would be a very simple test, which can rule out obvious non-random results, but is still by far too simplistic to check for really random behaviour.

See the Wikipedia page about Randomness Tests as a collection of links to primary sources regarding this. They do mention a good amount of quite complicated-sounding concepts; it is it not so important to go into deep detail about this - but it is clear that it is not intuitively possible to declare a specific number to be a good source for such digits.

On a positive note: For a specific irrational number, you are of course free to just try it; i.e., calculate the number to a sufficiantly large degree of digits, and run it through all known tests (there are tools for that, see above link). If the measure is good enough for your use case, and if you are aware that this is obviously useless for cryptographical applications, and always get the same numbers if you should start over, and that the quality might degrade if you get past the n you picked for testing the randomness, you could use those numbers. But it will be far better to use a dedicated (pseudo-)random number generator; and nothing beats a good physical source of randomness.

AnoE
  • 1,303
  • 8
  • 10
2

It provides a good random number right until you realize how it was produced, as with many pseudo random number. The irrational (non algebraic and non transcendental) numbers you have chosen are common and so easier guessed then others. I can see no issue with this method provided you choose less commonly seen generators.

1

I know this is old, but I can't help but see that the accepted answer is not quite right... so here we go:

Most pseudo random number generators leverage an irrational ratio somewhere in their calculation, because as your intuition suggests, irrational figures are the best source we have to a chaotic sequence of values. Many small implementations of PRNGs you can find in text books, and other such resources utilize a so called "magic number" that is actually a representation of an irrational figure -- for example a value which closely approximates the irrational figure relative to available fidelity of the medium -- and generates output by progressively applying a trivial arithmetic transform -- for example by having stored a seed value that is multiplied and asigned to by the "magic number" -- and returning it.

Ultimately a PRNG has a full cycle of values for any given seed that it will progressively output ad infinitum. The length of the cycles, and how many independent cycles there are and other qualities of the pseudo random sequences are a function of the irrational number used at the core of the algorithm. The golden ratio or phi is proposed as the MOST irrational number, and hypothetically a decent approximation of phi applied to the approach will result in a PRNG that has a single cycle that includes all the possible outputs of the medium, which is great!

Unfortunately, due to the nature of this generation, the cycle is deterministic and repeated ad nausea. This necessarily result in limited domain of ultimately predictable, and reproducible "chaos" that will not include permutations of sub-sequences of the PRNG output. It would literally output EVERY other value it could before it repeated itself, however an application could apply arithmetic operations such as floor, cieling, modulos, integer division, clamping, and so forth to map the many PRNG output values to a desired domain of fewer values, thus obtaining permutations of the fewer values within the desired domain. You Essentially have to throw away some fidelity to get permutations.

Alternatively you can devise a PRNG algorithm that takes into consideration multiple prior outputs, exponentially expanding the potential cycle length, and/or leverages a cycle of irrational figures (potentially from another PRNG) to really mix things up. This would be similar in approach to the enigma machines of WWII that introduces more chaos into the encoding of messages by way of a hidden progressing sequence of arithmetic modifications to determine the encoding of the next symbol. A good example of a method to generating irrational numbers, is to apply exponents to phi. However it should be noted that all irrational numbers you could compute through such means are LESS irrational than phi itself unless the exponent is 1, and especially so if the exponent is 0.

I hope that helped someone.