Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Well, if you seed both <code>Random</code> instances with the same value, you will definitely not get quality discrete uniform distribution. Consider the most basic case, which literally prints the exact same number twice (doesn't get much less random than that ...):</p> <pre><code>public class RngTest2 { public static void main(String[] args) throws Exception { long currentTime = System.currentTimeMillis(); Random r1 = new Random(currentTime); Random r2 = new Random(currentTime); System.out.println(r1.nextInt()); System.out.println(r2.nextInt()); } } </code></pre> <p>But that's just a single iteration. What happens if we start cranking up the sample size?</p> <p>Here is a scatter plot of a distribution from running two same-seeded RNGs side-by-side to generate 2000 numbers total:</p> <p><img src="https://i.stack.imgur.com/7kIyO.jpg" alt="alt text"></p> <p>And here is a distribution of running a single RNG to generate 2000 numbers total:</p> <p><img src="https://i.stack.imgur.com/9402v.jpg" alt="alt text"></p> <p>It seems pretty clear which approach produced higher quality discrete uniform distribution over this finite set.</p> <p>Now almost everyone knows that seeding two RNGs with the same seed is a bad idea if you're looking for high quality randomness. But this case does make you stop and think: we <em>have</em> created a scenario where each RNG is independently emitting fairly high quality randomness, but when their output is combined it is notably lower in quality (less discrete.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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