## Saturday, February 23, 2019

### Pseudo Random Numbers

If you aren't interested in random numbers just skip this post.
Keep in mind that there is content here and log it for later. At some point in the future random numbers will be a valuable commodity.

The reason I made that last statement is that privacy is increasingly important and that privacy depends on good and absolutely random numbers. So why am I blogging about pseudo random numbers? After all, they're not really random. There may be times when you may not have true random numbers available to you. If pseudo random numbers are all you have they'll be better than nothing. This post shows you how to create PRN's on a cheap calculator. The calculations can be done with pencil and paper but a calculator like the one above will be quicker. I recently bought a similar one in a charity shop for £3. An even cheaper non scientific calculator will work for this also.

If your curiosity has got you this far I'd recommend watching a really good video on YouTube. It's just under 15 minutes long. The calculation used for the Linear Congruential Generator wasn't explained in simple enough terms for me so that's what I plan to do here.

How would you interpret the equation in the video so as to resolve it on a calculator? Here's how.

First the equation:
(seed · a + c) mod m

Where seed = starting value, m = modulus, a = multiplier, c = increment.
The values in the video would make the equation as follows.

(4321 · 378 + 2310) mod 7829

On your calculator press the following keys:

4321 x 378 + 2310 =

The result will be 1635648. Write this down or just leave it on screen if your calculator lets you calculate an answer. We'll be using this figure for the mod part below.
Let's just say you've cleared your screen, key in:

1635648 ÷ 7829 =

The result is 208.922. Next subtract 208 from the last answer as follows:

208.922 - 208 =

All we did there is to subtract the number before the decimal point which in this case was 208. The result is now 0.922.
Take this answer and multiply it by your modulator which in our case is 7829.

0.922 x 7829 =

The answer is 7216 which is the same answer in the video linked above.
This number is now the new modulator. Just keep repeating the steps above until you have enough pseudo random numbers.

The numbers used above can be whatever you like but as mentioned in the video the higher the modulus the better.
I'll be covering other methods of obtaining pseudo random numbers soon and later methods for true random numbers. Pseudo random numbers are fairly easy to create and can also be used for creating true random numbers.
More on that another day.
If you've made it this far, well done.