vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Why doesn't setseed complain when given a seed value outside of its expected range? The documentation claims that 0 -> 1 should be used, but shouldn't it actually be -1 -> 1 to get the full range of the seed? If passed a value outside this range you always get the same value which isn't going to produce a good random number stream. Kris Jurka ---------------------------(end of broadcast)--------------------------- TIP 2: Don't 'kill -9' the postmaster |
| |||
| Kris Jurka <books@ejurka.com> writes: > Why doesn't setseed complain when given a seed value outside of its > expected range? Why should it complain? The use of the value is totally unspecified anyway. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| On Wed, 11 Apr 2007, Tom Lane wrote: > Kris Jurka <books@ejurka.com> writes: >> Why doesn't setseed complain when given a seed value outside of its >> expected range? > > Why should it complain? The use of the value is totally unspecified > anyway. > Because the user is likely using it incorrectly. I'm not sure what you mean by totally unspecified. The documentation[1] states: set seed for subsequent random() calls (value between 0 and 1.0) When a user calls setseed(5), setseed(500), or setseed(-500) they get the same seed value each time which is surely not what they intended. At minimum I think it should raise a warning. Also I think that documentation should be corrected to indicate that vaules -1 to 1 are the correct seed value range or it should it should map 0->1 to the entire seed space, not just half of it as is currently done. The decision of which change to make is unclear because it's a change to either the call signature or to the generated values for a given user supplied seed. Kris Jurka [1] http://www.postgresql.org/docs/8.2/s...ATH-FUNC-TABLE ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend |
| |||
| Kris Jurka <books@ejurka.com> writes: > On Wed, 11 Apr 2007, Tom Lane wrote: >> Kris Jurka <books@ejurka.com> writes: >>> Why doesn't setseed complain when given a seed value outside of its >>> expected range? >> >> Why should it complain? The use of the value is totally unspecified >> anyway. > Because the user is likely using it incorrectly. It's not really possible to use it "incorrectly", AFAICS. Any value you might pass to it will result in a specific new seed value. Nowhere is there any guarantee of what the mapping is, and it's obviously impossible to guarantee that the mapping is one-to-one, so any user assumptions about what a specific seed value might "mean" seem broken regardless. regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| Kris Jurka <books@ejurka.com> writes: > On Wed, 11 Apr 2007, Tom Lane wrote: >> It's not really possible to use it "incorrectly", AFAICS. Any value you >> might pass to it will result in a specific new seed value. Nowhere is >> there any guarantee of what the mapping is, and it's obviously >> impossible to guarantee that the mapping is one-to-one, so any user >> assumptions about what a specific seed value might "mean" seem broken >> regardless. > Then please consider this patch which checks the range and maps the > provided value to the entire seed space. I'm still not very happy about this. It'll change the behavior of existing applications, in the service of no goal that I consider convincing. I'd be inclined to leave the mapping alone and just insert a warning (or hard error) for inputs outside the range -1 to 1. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs |
| ||||
| Kris Jurka <books@ejurka.com> writes: > On Mon, 10 Mar 2008, Tom Lane wrote: >> I'd be inclined to leave the mapping alone and just insert a warning >> (or hard error) for inputs outside the range -1 to 1. > Here's a patch that errors out for out of range values. Applied, thanks. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs |
| Thread Tools | |
| Display Modes | |
|
|