Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding "randomness"

I can't get my head around this, which is more random?

rand() 

OR:

rand() * rand() 

I´m finding it a real brain teaser, could you help me out?


EDIT:

Intuitively I know that the mathematical answer will be that they are equally random, but I can't help but think that if you "run the random number algorithm" twice when you multiply the two together you'll create something more random than just doing it once.

like image 879
Trufa Avatar asked Oct 18 '10 03:10

Trufa


People also ask

What are the two components of randomness?

The need to distinguish two components in randomness was clear: the generation process (random experiment) and the pattern of the random sequences produced.

What is randomness and why is it so important in statistics?

Randomness has very important applications in many areas of mathematics. In statistics, the selection of a random sample is important to ensure that a study is conducted without bias. A simple random sample is obtained by numbering every member of the population of interest, and assigning each member a numerical label.

Is there randomness in the universe?

With randomness in Nature, the universe could not have been predetermined completely in the sense that it should be impossible in principle to compute from the big bang or at any later moment whether live and conscious observers might or might not appear there.

How is randomness used in statistics?

The fields of mathematics, probability, and statistics use formal definitions of randomness. In statistics, a random variable is an assignment of a numerical value to each possible outcome of an event space. This association facilitates the identification and the calculation of probabilities of the events.


2 Answers

I guess both methods are as random although my gutfeel would say that rand() * rand() is less random because it would seed more zeroes. As soon as one rand() is 0, the total becomes 0

like image 22
3 revs, 3 users 60% Avatar answered Oct 04 '22 13:10

3 revs, 3 users 60%


Just a clarification

Although the previous answers are right whenever you try to spot the randomness of a pseudo-random variable or its multiplication, you should be aware that while Random() is usually uniformly distributed, Random() * Random() is not.

Example

This is a uniform random distribution sample simulated through a pseudo-random variable:

Histogram of Random()

        BarChart[BinCounts[RandomReal[{0, 1}, 50000], 0.01]] 

While this is the distribution you get after multiplying two random variables:

Histogram of Random() * Random()

        BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] *                                   RandomReal[{0, 1}, 50000], {50000}], 0.01]] 

So, both are “random”, but their distribution is very different.

Another example

While 2 * Random() is uniformly distributed:

Histogram of 2 * Random()

        BarChart[BinCounts[2 * RandomReal[{0, 1}, 50000], 0.01]] 

Random() + Random() is not!

Histogram of Random() + Random()

        BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] +                                   RandomReal[{0, 1}, 50000], {50000}], 0.01]] 

The Central Limit Theorem

The Central Limit Theorem states that the sum of Random() tends to a normal distribution as terms increase.

With just four terms you get:

Histogram of Random() + Random() + Random() + Random()

BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] + RandomReal[{0, 1}, 50000] +                    Table[RandomReal[{0, 1}, 50000] + RandomReal[{0, 1}, 50000],                    {50000}],          0.01]]   

And here you can see the road from a uniform to a normal distribution by adding up 1, 2, 4, 6, 10 and 20 uniformly distributed random variables:

Histogram of different numbers of random variables added

Edit

A few credits

Thanks to Thomas Ahle for pointing out in the comments that the probability distributions shown in the last two images are known as the Irwin-Hall distribution

Thanks to Heike for her wonderful torn[] function

like image 177
Dr. belisarius Avatar answered Oct 04 '22 14:10

Dr. belisarius