Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does adding random numbers make them more random?

Tags:

random

This is a purely theoretical question.

We all know that most, if not all, random-number generators actually only generate pseudo-random numbers.

Let's say I want a random number from 10 to 20. I can do this as follows (myRandomNumber being an integer-type variable):

myRandomNumber = rand(10, 20);

However, if I execute this statement:

myRandomNumber = rand(5, 10) + rand(5, 10);

Is this method more random?

like image 487
apparatix Avatar asked Nov 16 '25 21:11

apparatix


1 Answers

No.

The randomness is not cumulative. The rand() function uses a uniform distribution between your two defined endpoints.

Adding two uniformly distributions invalidates the uniform distribution. It will make a strange looking pyramid, with the most probability tending toward the center. This is because of accumulation of the probability density function with increasing degrees of freedom.

I urge you to read this:

Uniform Distribution

and this:

Convolution

Pay special attention to what happens with the two uniform distributions on the top right of the screen.

You can prove this to yourself by writing to a file all the sums and then plotting in excel. Make sure you give yourself a large enough sample size. 25000 should be sufficient.

like image 124
Tyler Jandreau Avatar answered Nov 19 '25 13:11

Tyler Jandreau



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!