This is the answer the OP is looking for.

Seeding a random number generator means giving it a number to start from - all "random number generators" that are not hooked to an actual source of entropy (like atomic decay, thermal noise, or the like) are simply doing calculations that return a sequence of numbers whose distribution looks random "enough". Knuth spends an entire volume of different definitions of "enough"; it's a very deep (and interesting) subject. (Most random number generators use a "linear congruential" calculation that essentially uses two largish numbers that are relatively prime to one another; the seed is multiplied by one, and then the product is reduced modulo the other. This has the advantage that it's a fairly fast operation (one multiply and one divide), and yields fairly good results.)

Seed functions exist to allow you to reproduce a given random sequence; this can be very useful when you're trying to test a module which contains a random component, as the behavior is still "random" (that is driven by the output of the rand() function) but at the same time completely predictable (since the sequence of numbers coming from rand() will be exactly the same every time for the same seed).


In reply to Re^2: srand producing the same sequence of random numbers by pemungkah
in thread srand producing the same sequence of random numbers by e_c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.