Open line-o opened 3 years ago
Can you comment on whether your expectations are rooted in the spec (relevant language, links), or whether the spec itself is, er, underspecified? Have you tested other implementations?
Good point @joewiz I added the relevant quote from the xquery 3.1 spec to the issue description. So I will change this to a feature as it is only recommended to be predictable between executions.
I want to state that the recommended behaviour is implemented for seeds with xs:integer values between 1 and 9223372036854775807.
I have not had a look at negative numeric values yet.
Describe the bug
When
fn:random-number-generator#1
is given any atomic value as a seed the resulting sequence of random numbers should be reproducible between two invocations.Given
fn:random-number-generator(1)
in existdb 5.3.0-SNAPSHOT the first random number that is returned is always, predictably5.31250253323421e-1
Moreover that is true for all following numbers as well. It is just unpredictable which number comes next until this was evaluated.
should evaluate to (at least for a specific version of existdb)
[5.31250253323421e-1, 5.313156098200126e-1]
This is very important to a whole range of applications working with seeded randoms. For testability, for generative algorithms and more.
While working on dicey I found a range of seeds where the assumptions above do not hold.
affected classes of seeds:
BONUS:
fn:random-number-generator(0)
(xs:integer zero as seed) will only return zeros!Expected behavior
The outcome of a random-number-generator seeded with any of the above to produce predictable random values across code executions and instances of existdb (at least of the same version).
To Reproduce
Context (please always complete the following information):
Additional context
conf.xml
? noneSpecification
https://www.w3.org/XML/Group/qtspecs/specifications/xpath-functions-31/html/Overview.html#func-random-number-generator