Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Linear congruential generators all suffer from a problem identified by George Marsaglia. "Marsaglia's Theorem" says that k-tuples (vectors of length k) will fall on a bounded number of hyperplanes. The bound is <code>m**(1/k)</code>, where k is the size of the tuple and m is the number used for the modulus of the generator. Thus, if the modulus is <code>(2**31 - 1)</code> and you're looking at sets of 3, a 3-d plot will show the points falling on no more than the cube root of <code>(2**31 - 1)</code>, or about 1290 planes, when viewed from the right orientation.</p> <p>All LCG's are subject to Marsaglia's Theorem. A "good" one performs at or close to the upper bound, a bad one falls well short of the upper bound. That's what the spectral test is effectively measuring, and that's what you were seeing in your Wikipedia link - RANDU, the LCG from hell, produces triplets that fall in a mere 15 planes.</p> <p>Apple's carbon library generator uses 16807 as its multiplier and <code>(2**31 - 1)</code> as its modulus. As LCG's go, it's not really all that bad. Hence your plot didn't show the same extremes RANDU has. However, if you want decent quality random numbers don't use an LCG.</p> <p><strong>Addendum</strong></p> <p>I've gone ahead and cranked a billion numbers from the Apple rand() function, but only printed the ones where both values of the pair were less than 2 million, i.e., the bottom left corner of your plot. Sure enough, they fall on lines. You just need to really zoom in to see it because of the density of lines.</p> <p>Old George was a clever fella!</p> <p><img src="https://i.stack.imgur.com/IFXJ5.png" alt="Marsaglia at work"></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. 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