2
$\begingroup$

I am working on a project and I'm reading this description on generating random bits in a file. They use the word "seed" in it. I've read what seed does, but I'm not quite sure how to apply it in this context.

"rand-src creates a file of random messages bits called source-file, which is suitable for testing the correctness and performance of other programs. The bits in the file are independent, and are equally likely to be 0 or 1. They are generated pseudo-randomly based on seed. The actual random number seed used will be seed times 10 plus 2, so that the stream of pseudo-random numbers will not be the same as any that might have been used by another program."

Can someone please clarify this? Sorry if i forgot to add any details. Please let me know and I will do so! thank you in advance!

$\endgroup$
4
$\begingroup$

This answer is perhaps a little too general, or hand-wavy. I don't know OPs background so I'm aiming at a upper high-school/college-freshman level.


So, here's a toyish story about how a RNG in your computer works. Encoded in your system is some sequence of functions $f_1, f_2, \dots, f_n$ that are highly nonlinear and sensitive to initial conditions. What that means is that $f_i(000000)$ is nowhere near $f_i(000001)$, even though those two bit-streams are really close together.

The generator asks you, or the machine, or some special chip for a number to start out with. This is the seed. It could be literally anything the computer understands, because the computer understands anything made up of bits, and all the functions want is a some bits to start out with. People even used to use photographs of a Lava Lamp.

Once it has a seed, the system runs this sequence of functions in some order to get numbers that 'look' random - of course they aren't, they're deterministically generated, but to a statistical test they look like they're coming from a dice roll or something. However, if you supply the same seed to the generator twice, it will spit out the same sequence of numbers. Herein lies the difference with true randomness. Since these numbers aren't random, but look like they are, they're called pseudo-random numbers, and the generator is called a pseudo-random number generator.

In case you want an example of a function that has these properties, the logistic map is a classic example, and was actually used to generate PRNs in early computers. If you have access to some programming resources, or MATLAB, you should try simulating this yourself. The map is the recurrence relation $$x_{n+1} = ax_n(1-x_n)$$

Set $a$ to something between $3$ and $4$, pick any $x_0 \in (0,1)$, and simulate the system for a few thousand turns, the output really looks random, even to statistical tests, and you'll also get the effect that using the same seed, here $x_0$, will give you the same sequence (Note: for something that truly looks random, you'll need to discard the first $1000$ or so terms - they have artifacts of the initial condition, and you don't want that)

Of course, the theory and practice of random number generation have been developing for decades, and much of what I say above is outdated, or even bordering on incorrect, but as a first introduction, this works. Hopefully this also clarifies the role of the seed - your functions need something to start out at, and it's in your interest to make it different each time. The quote from the program is trying to do this - in case you re-use a seed that you'd used somewhere before, it modifies it a bit so that the common RNG both programs use gets a different input, and churns out a different sequence of numbers.

$\endgroup$
  • $\begingroup$ That was very very informative, thank you! $\endgroup$ – Jonathan Dec 19 '15 at 21:16
  • $\begingroup$ Quick question: Can you please tell me what the acronym OP stands for? Thank you! $\endgroup$ – Jonathan Dec 19 '15 at 23:06
  • $\begingroup$ Aw, you haven't been internet-ting long have you? OP is Original Poster, derived from forum based websites, the most popular of which today is reddit.com $\endgroup$ – stochasticboy321 Dec 20 '15 at 2:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.