1
$\begingroup$

If I have 2 true random numbers from atmospheric noise or a different source. Suppose $x= 299$ and $y= 499$. Is it possible to create a bigger number with $x$ to the power of $y$?

Can I use different sources like, pressure sensor + light sensor + movement sensor and calculate $x^{y^z}$ for a true random number?

$\endgroup$
2
$\begingroup$

Raising to powers isn't how you'd want to go about it. For instance, lets say my true random number generator gave me x=3 and y=5, and lets say it usually generates numbers between 0 and 7. That's 3 bits of randomness per value. If I generate two of them, I will have 6 bits of randomness. If I output x^y as the result, then it has the potential to output anything from 1 to 823543 (7^7). This is around a 20 bit value coming from only 6 bits of entropy (the technical term for randomness). This will be very biased.

A better way, if your RNG (random number generator) outputs with a range of a power of 2 (1 to 8, 0 to 15, 20 to 23, etc), then you can get the random bits and simply concatenate to get a larger number. For example, from the earlier example, 3 can become "011" and 5 can become "101". The resulting number can then be "011101" or 29. This (assuming the RNG is uniform across 0 and 7) will be uniform across 0 and 63.

However, if your RNG is biased, or outputs with a range that's not a power of 2, then you can use a cryptographic hash function to "mix" the randomness. If your RNG outputs uniformly between 0 and 99 (a range of 100), then each value is 6.6439 ( $log_2(100)$ ) bits of entropy. You can collect enough values to have at least 256 bits (in this case, 39 values) and run them all through a 256 bit hash function (such as SHA256). The output of this will be 256 uniformly distributed bits.

In the last example, it's important to put a delimiter between the random values before hashing them. For instance, if you get the values 3, 6, 5, and 1, then hash "3,6,5,1" not "3651".

Of course, this all assumes you want the output to be truly random. If you're okay with pseudorandom, then you can use the output of your RNG as the seed of a PRNG at a much greater speed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.