setseed() doc

Started by Dennis Bjorklundover 19 years ago8 messages
#1Dennis Bjorklund
db@zigo.dhs.org
1 attachment(s)

The doc doesn't state in what range the argument to setseed() should be.

Some tests suggest that only values in the range -1.0 to 1.0 work as a
seed and values outside of that give the same sequence of random numbers.

I've attached a trivial one line patch (this is the patch list after
all), but feel free to document it in any way that is appropriate.

setseed() also return an integer, but I have no clue of what it is. The
doc doesn't say anything about it.

The doc say that some functions here depend on the libc that is used,
but such things as the range of the argument and what the return value
is should be in the doc, shouldn't it?

/Dennis

Attachments:

setseed.txttext/plain; name=setseed.txtDownload
Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.332
diff -u -r1.332 func.sgml
--- doc/src/sgml/func.sgml	22 Aug 2006 00:49:19 -0000	1.332
+++ doc/src/sgml/func.sgml	4 Sep 2006 18:18:26 -0000
@@ -795,7 +795,7 @@
       <row>
        <entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
        <entry><type>int</type></entry>
-       <entry>set seed for subsequent <literal>random()</literal> calls</entry>
+       <entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and 1.0)</entry>
        <entry><literal>setseed(0.54823)</literal></entry>
        <entry><literal>1177314959</literal></entry>
       </row>
#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dennis Bjorklund (#1)
Re: setseed() doc

Dennis Bjorklund <db@zigo.dhs.org> writes:

<entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
<entry><type>int</type></entry>
-       <entry>set seed for subsequent <literal>random()</literal> calls</entry>
+       <entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and 1.0)</entry>

Looking at the code, it would appear that the intended range is 0 to 1.

regards, tom lane

#3Dennis Bjorklund
db@zigo.dhs.org
In reply to: Tom Lane (#2)
Re: setseed() doc

Tom Lane skrev:

<entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
<entry><type>int</type></entry>
-       <entry>set seed for subsequent <literal>random()</literal> calls</entry>
+       <entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and 1.0)</entry>

Looking at the code, it would appear that the intended range is 0 to 1.

Ok.

What about the return value? The doc didn't say anything about it.

/Dennis

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dennis Bjorklund (#3)
Re: setseed() doc

Dennis Bjorklund <db@zigo.dhs.org> writes:

What about the return value? The doc didn't say anything about it.

AFAICT it's just junk. It happens to be the input times
MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
change the function to return VOID ... that option wasn't available
when it was coded originally, else it'd probably have been done that
way.

regards, tom lane

#5Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#2)
1 attachment(s)
Re: setseed() doc

Tom Lane wrote:

Dennis Bjorklund <db@zigo.dhs.org> writes:

<entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
<entry><type>int</type></entry>
-       <entry>set seed for subsequent <literal>random()</literal> calls</entry>
+       <entry>set seed for subsequent <literal>random()</literal> calls (value between -1.0 and 1.0)</entry>

Looking at the code, it would appear that the intended range is 0 to 1.

Docs updated.

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachments:

/bjm/difftext/x-diffDownload
Index: doc/src/sgml/func.sgml
===================================================================
RCS file: /cvsroot/pgsql/doc/src/sgml/func.sgml,v
retrieving revision 1.332
diff -c -c -r1.332 func.sgml
*** doc/src/sgml/func.sgml	22 Aug 2006 00:49:19 -0000	1.332
--- doc/src/sgml/func.sgml	4 Sep 2006 21:45:15 -0000
***************
*** 795,801 ****
        <row>
         <entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
         <entry><type>int</type></entry>
!        <entry>set seed for subsequent <literal>random()</literal> calls</entry>
         <entry><literal>setseed(0.54823)</literal></entry>
         <entry><literal>1177314959</literal></entry>
        </row>
--- 795,801 ----
        <row>
         <entry><literal><function>setseed</function>(<type>dp</type>)</literal></entry>
         <entry><type>int</type></entry>
!        <entry>set seed for subsequent <literal>random()</literal> calls (value between 0 and 1.0)</entry>
         <entry><literal>setseed(0.54823)</literal></entry>
         <entry><literal>1177314959</literal></entry>
        </row>
#6Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#4)
Re: setseed() doc

On Mon, 2006-09-04 at 15:19 -0400, Tom Lane wrote:

AFAICT it's just junk. It happens to be the input times
MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
change the function to return VOID

I agree. Given how soon we want to get an 8.2 beta out the door, perhaps
this change would be best postponed to 8.3 (unless there's another
outstanding 8.2 patch that requires initdb?).

-Neil

#7Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#6)
Re: [HACKERS] setseed() doc

Neil Conway <neilc@samurai.com> writes:

On Mon, 2006-09-04 at 15:19 -0400, Tom Lane wrote:

AFAICT it's just junk. It happens to be the input times
MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
change the function to return VOID

I agree. Given how soon we want to get an 8.2 beta out the door, perhaps
this change would be best postponed to 8.3 (unless there's another
outstanding 8.2 patch that requires initdb?).

Nothing outstanding at the moment.

Although this is surely a small change, it's also pretty low-priority,
so I'd counsel leaving it for 8.3 rather than trying to cram it in now.
We have more important things to be worrying about ...

regards, tom lane

#8Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#7)
Re: [HACKERS] [PATCHES] setseed() doc

FYI, Neil has corrected this in CVS HEAD.

---------------------------------------------------------------------------

Tom Lane wrote:

Neil Conway <neilc@samurai.com> writes:

On Mon, 2006-09-04 at 15:19 -0400, Tom Lane wrote:

AFAICT it's just junk. It happens to be the input times
MAX_RANDOM_VALUE, but what use is that? I wonder if we shouldn't
change the function to return VOID

I agree. Given how soon we want to get an 8.2 beta out the door, perhaps
this change would be best postponed to 8.3 (unless there's another
outstanding 8.2 patch that requires initdb?).

Nothing outstanding at the moment.

Although this is surely a small change, it's also pretty low-priority,
so I'd counsel leaving it for 8.3 rather than trying to cram it in now.
We have more important things to be worrying about ...

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org

--
Bruce Momjian bruce@momjian.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +