Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<h1>Just a clarification</h1> <p>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 <strong>Random()</strong> is usually uniformly distributed, <strong>Random() * Random()</strong> is not. </p> <h2>Example</h2> <p>This is a <a href="http://en.wikipedia.org/wiki/Uniform_distribution_(continuous)" rel="noreferrer">uniform random distribution sample</a> simulated through a pseudo-random variable:</p> <p><img src="https://i.stack.imgur.com/M6XTU.png" alt="Histogram of Random()"> </p> <pre><code> BarChart[BinCounts[RandomReal[{0, 1}, 50000], 0.01]] </code></pre> <p>While this is the distribution you get after multiplying two random variables:</p> <p><img src="https://i.stack.imgur.com/S3Oaa.png" alt="Histogram of Random() * Random()"> </p> <pre><code> BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] * RandomReal[{0, 1}, 50000], {50000}], 0.01]] </code></pre> <p>So, both are “random”, but their distribution is very different.</p> <h2>Another example</h2> <p>While <strong>2 * Random()</strong> is uniformly distributed:</p> <p><img src="https://i.stack.imgur.com/XsFWW.png" alt="Histogram of 2 * Random()"></p> <pre><code> BarChart[BinCounts[2 * RandomReal[{0, 1}, 50000], 0.01]] </code></pre> <p><strong>Random() + Random() is not!</strong></p> <p><img src="https://i.stack.imgur.com/OyqWF.png" alt="Histogram of Random() + Random()"></p> <pre><code> BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] + RandomReal[{0, 1}, 50000], {50000}], 0.01]] </code></pre> <h2>The Central Limit Theorem</h2> <p><strong>The <a href="http://en.wikipedia.org/wiki/Central_limit_theorem" rel="noreferrer">Central Limit Theorem</a> states that the sum of <em>Random()</em> tends to a <a href="http://en.wikipedia.org/wiki/Normal_distribution" rel="noreferrer">normal distribution</a> as terms increase.</strong></p> <p>With just four terms you get:</p> <p><img src="https://i.stack.imgur.com/VWnJE.png" alt="Histogram of Random() + Random() + Random() + Random()"></p> <pre><code>BarChart[BinCounts[Table[RandomReal[{0, 1}, 50000] + RandomReal[{0, 1}, 50000] + Table[RandomReal[{0, 1}, 50000] + RandomReal[{0, 1}, 50000], {50000}], 0.01]] </code></pre> <p>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:</p> <p><img src="https://i.stack.imgur.com/Apmgz.png" alt="Histogram of different numbers of random variables added"></p> <p><strong>Edit</strong></p> <p>A few credits</p> <p>Thanks to <a href="https://stackoverflow.com/users/205521/thomas-ahle">Thomas Ahle</a> for pointing out in the comments that the probability distributions shown in the last two images are known as the <a href="http://en.wikipedia.org/wiki/Irwin%E2%80%93Hall_distribution" rel="noreferrer">Irwin-Hall distribution</a> </p> <p>Thanks to <a href="https://mathematica.stackexchange.com/users/46/heike">Heike</a> for her wonderful <a href="https://mathematica.stackexchange.com/a/4155/193">torn[] function</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload