# Seeding a random number generator with a RNG

**URL:** <https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698>\
**Category:** Factual Questions\
**Created:** [August 21, 2003, 3:33pm UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698 "2003-08-21T15:33:44Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![ftg](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/ftg/32/2801_2.png) [@ftg](https://boards.straightdope.com/u/ftg)\
**Post date:** [August 22, 2003, 5:06am UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698/21 "2003-08-22T05:06:29Z")

</div>

There is serious research on this subject in Computer Science. It has actually been presented in papers methods where you can start with a smallish random seed to generate a very large “cryptographically secure” large random sequence.

Note that the laws of randomness as used in this context means that there is no way the result is any more random than the input, but it is in some way provably less “pseudorandom” than what people are talking about here. I.e., you can generate stuff practically as good as one-time-pads using random keys a lot shorter than the message length. (But they have other nice applications.)

If you want to read such papers, I suggest the conference proceedings from _The ACM Symposium on Theory of Computing_ or _IEEE Foundations of Computer Science_ from about 1994 or so if my memory is correct as to when these results first came out.

---

<div class="post-metadata">

**Author:** ![Desmostylus](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@Desmostylus](https://boards.straightdope.com/u/Desmostylus)\
**Post date:** [August 22, 2003, 7:34am UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698/22 "2003-08-22T07:34:51Z")

</div>

Randomness can be improved by using more than one pseudo-random number generator, but not by using one to seed the other.

I don’t have a copy of Knuth handy, but here’s a second hand quote from Press, Flannery et al:

> [@](#):
>
> RAN1 is based on three linear congruential generators from the above table. One generator is used for the most significant part of the output number, the second for the least significant part, and the third to control a shuffling routine (here absolutely essential because of the relatively small values of the multiplier m available to us). The shuffling routine… is one which has been suggested by Knuth and widely used. RAN1 is, of course, very much better than any of its three generators individually: its period is (for all practical purposes) infinite, and it ought to have no sensible sequential correlations. The choice of which constants from the accompanying table to use is arbitrary, as is the length of the shuffling array.

---

<div class="post-metadata">

**Author:** ![Desmostylus](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@Desmostylus](https://boards.straightdope.com/u/Desmostylus)\
**Post date:** [August 22, 2003, 10:04am UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698/23 "2003-08-22T10:04:07Z")

</div>

That should read “second hand _cite_, in this quote…”

---

<div class="post-metadata">

**Author:** ![Shalmanese](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Shalmanese](https://boards.straightdope.com/u/Shalmanese)\
**Post date:** [August 22, 2003, 11:50am UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698/24 "2003-08-22T11:50:28Z")

</div>

Uhm, its actually suprisingly hard to think up a “good” random number generating algorithm. Paradoxically, making things more complicated quite often makes it WORSE, it some cases, much, much worse. I can guarentee that double seeding is provably no better than a good single seeding algorithm and can be worse depending on how it is implemented.

---

<div class="post-metadata">

**Author:** ![Desmostylus](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@Desmostylus](https://boards.straightdope.com/u/Desmostylus)\
**Post date:** [August 22, 2003, 12:05pm UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698/25 "2003-08-22T12:05:08Z")

</div>

> [@](#):
>
> \*Originally posted by Shalmanese \*  
> \*\*Uhm, its actually suprisingly hard to think up a “good” random number generating algorithm. Paradoxically, making things more complicated quite often makes it WORSE, it some cases, much, much worse. I can guarentee that double seeding is provably no better than a good single seeding algorithm and can be worse depending on how it is implemented. \*\*

I’m finding this a bit hard to follow, **Shalmanese**.

What do you mean by “random number generating algorithm”? A truly random generator or a pseudo-random generator?

And I’m unfamiliar with the term “double seeding”. What’s that mean?

---

<div class="post-metadata">

**Author:** ![Desmostylus](https://avatars.discourse-cdn.com/v4/letter/d/c57346/32.png) [@Desmostylus](https://boards.straightdope.com/u/Desmostylus)\
**Post date:** [August 22, 2003, 12:08pm UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698/26 "2003-08-22T12:08:10Z")

</div>

> [@](#):
>
> \*Originally posted by Desmostylus \*  
> \*\*And I’m unfamiliar with the term “double seeding”. What’s that mean? \*\*

Forget that. I assume you just mean “Seeding a random number generator with a RNG”.

---

<div class="post-metadata">

**Author:** ![dtilque](https://avatars.discourse-cdn.com/v4/letter/d/d6d6ee/32.png) [@dtilque](https://boards.straightdope.com/u/dtilque)\
**Post date:** [August 22, 2003, 8:53pm UTC](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698/27 "2003-08-22T20:53:20Z")

</div>

> [@](#):
>
> \*Originally posted by Pleonast \*  
> (In fact, simply adding the outputs of two RNGs will typically generate a RNG with a cycle length equal to the product of the two cycle lengths.)

Adding two random number will give a random number with a different probability distribution. Example: one six sided die produces a random integer between 1 and 6 with a flat distribution. Adding the output of two dice produces a random number between 2 and 12 with a bell shaped distribution.

To extend the cycle length with more than one RNG and without changing the probability distribution[sup]1[/sup], simply alternate between the RNGs. The cycle length will then be the number of RNGs times product of all the cycle lengths divided by the greatest common divisor of the cycle lengths.  
[sup]1[/sup] This assumes all RNGs have the same distribution.

[Previous page](https://boards.straightdope.com/t/seeding-a-random-number-generator-with-a-rng/196698.md?page=1)
