Thread

Commits

  1. Doc: improve documentation about random().

  1. What seed does random() use if setseed() is not called first?

    Carl Sopchak <carl@sopchak.me> — 2022-07-23T21:18:40Z

    <html>
      <head>
    
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      </head>
      <body>
        <p>There is one point about the documentation for random() and
          setseed() that is missing.  What is used to seed random() if
          setseed() isn't called first?  I assume it's something like
          /dev/random or /dev/urandom, but that's just a guess.  Can someone
          please enlighten me?</p>
        <p>Thanks for the help!</p>
        <p>Carl<br>
        </p>
      </body>
    </html>
    
    
    
    
  2. Re: What seed does random() use if setseed() is not called first?

    Tom Lane <tgl@sss.pgh.pa.us> — 2022-07-23T21:47:19Z

    Carl Sopchak <carl@sopchak.me> writes:
    >     <p>There is one point about the documentation for random() and
    >       setseed() that is missing.  What is used to seed random() if
    >       setseed() isn't called first?  I assume it's something like
    >       /dev/random or /dev/urandom, but that's just a guess.  Can someone
    >       please enlighten me?</p>
    
    We don't document this because it's platform- and version-dependent,
    but yeah, generally /dev/urandom or local equivalent.
    
    			regards, tom lane
    
    
    
    
  3. Re: What seed does random() use if setseed() is not called first?

    Carl Sopchak <carl@sopchak.me> — 2022-07-23T21:55:40Z

    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      </head>
      <body>
        <p>Thank you for the quick reply!  But I wouldn't have bothered you
          if the documentation stated something to the effect of "While it's
          platform-dependent, if setseed() is not called, the random number
          generator is generally seeded by whatever method the operating
          system provides as a source of randomness, such as /dev/urandom on
          Linux/Unix, or &lt;???&gt; on Windows."</p>
        <p>Just a suggestion, hope this helps, and thanks again!</p>
        <p>Carl<br>
        </p>
        <div class="moz-cite-prefix">On 7/23/22 17:47, Tom Lane wrote:<br>
        </div>
        <blockquote type="cite" cite="mid:1220338.1658612839@sss.pgh.pa.us">
          <pre class="moz-quote-pre" wrap="">Carl Sopchak <a class="moz-txt-link-rfc2396E" href="mailto:carl@sopchak.me">&lt;carl@sopchak.me&gt;</a> writes:
    </pre>
          <blockquote type="cite">
            <pre class="moz-quote-pre" wrap="">    &lt;p&gt;There is one point about the documentation for random() and
          setseed() that is missing.  What is used to seed random() if
          setseed() isn't called first?  I assume it's something like
          /dev/random or /dev/urandom, but that's just a guess.  Can someone
          please enlighten me?&lt;/p&gt;
    </pre>
          </blockquote>
          <pre class="moz-quote-pre" wrap="">
    We don't document this because it's platform- and version-dependent,
    but yeah, generally /dev/urandom or local equivalent.
    
    			regards, tom lane
    </pre>
        </blockquote>
      </body>
    </html>
    
    
    
    
  4. Re: What seed does random() use if setseed() is not called first?

    Tom Lane <tgl@sss.pgh.pa.us> — 2022-07-23T22:06:01Z

    Carl Sopchak <carl@sopchak.me> writes:
    >     <p>Thank you for the quick reply!  But I wouldn't have bothered you
    >       if the documentation stated something to the effect of "While it's
    >       platform-dependent, if setseed() is not called, the random number
    >       generator is generally seeded by whatever method the operating
    >       system provides as a source of randomness, such as /dev/urandom on
    >       Linux/Unix, or &lt;???&gt; on Windows."</p>
    
    Hmm, I thought this already was documented, but it looks like not.
    I'll see what I can do.
    
    			regards, tom lane
    
    
    
    
  5. Re: What seed does random() use if setseed() is not called first?

    Carl Sopchak <carl@sopchak.me> — 2022-07-23T22:09:29Z

    
      If it is, somewhere, it's not on the Mathematical Functions page where random() and setseed() are documented.
    
    
    
      
    
    
    
      Thanks again...
    
    
    
      Carl
    
    
    
      
    
    
    
      On 7/23/22 18:06, Tom Lane wrote:
    
    
    
      Carl Sopchak <carl@sopchak.me> writes:
    
      
            <p>Thank you for the quick reply!  But I wouldn't have bothered you
          if the documentation stated something to the effect of "While it's
          platform-dependent, if setseed() is not called, the random number
          generator is generally seeded by whatever method the operating
          system provides as a source of randomness, such as /dev/urandom on
          Linux/Unix, or &lt;???&gt; on Windows."</p>
    
      
      
    Hmm, I thought this already was documented, but it looks like not.
    I'll see what I can do.
    
                            regards, tom lane